Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

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

(0) ShareShare
ReportReport
Posted on by 873

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,056 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans