Skip to main content

Notifications

Dynamics 365 general forum
Suggested answer

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

Posted on by 865

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

  • Suggested answer
    Nya Profile Picture
    Nya 29,054 on at
    RE: FetchXML - System View for Last Expired Agreements for a service account

    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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans