web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

FetchXML - System View for Last Expired Agreements for a service account

(0) ShareShare
ReportReport
Posted on by 905

Hello,

In the agreement entity in the field service module I have a bunch of historical records for every service account that are (Active and Expired).

What I want to achieve is the below:

I want to build a custom fetchXML query that should only find the LAST expired agreement(s) for a service account with taking into consideration the below condition:

  1. If a service account has an "Active Agreement" as the last record, this account should not be included in the View that should be created. However, If the service account his last agreement is expired this record should be included In the view.

Below is an example:

Service Account = "Test1", Agreement Status = "Expired"
Service Account = "Test1", Agreement Status = "Canceled"

Service Account = "Test", Agreement Status = "Active"
Service Account = "Test", Agreement Status = "Expired"

Based on the above example, the Service Account Test1 should be visible on the view and returned as a result of the query because his last agreement is expired.

From the advanced find, I am not able to achieve this requirement with the condition needed.

Could you please provide an example or a sample to achieve the above requirements? If it is feasible, simply I can use the View designer on XRMToolBox to alter the system view that I want based on the query needed.

Any help is highly appreciated.

Best regards,
EBMRay

I have the same question (0)
  • Suggested answer
    Nya Profile Picture
    29,060 on at

    Hi EBMRay,

    According to your example, it needs to retrieve last child record first, which cannot be done with FetchXML only.

    Please refer to the following issue:

    (+) FetchXML to retrieve last child record - Microsoft Dynamics CRM Forum Community Forum

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans