Hi All,
Can anyone please help in how to get the top 1 contact associated with each Account. An account can have more than 1 contact so I wanted to get only 1 contact for each account using FetchXml.
Thanks in Advance!
Hi All,
Can anyone please help in how to get the top 1 contact associated with each Account. An account can have more than 1 contact so I wanted to get only 1 contact for each account using FetchXml.
Thanks in Advance!
Hi prasanna05,
As Guido Preite says, only through fetchxml can't achieve this because "top" or "page" "count" can't work on child record. You could refer to this thread:
https://stackoverflow.com/questions/22096633/auto-numbering-to-parent-and-child-columns
In this thread, he achieved this by indexing the entity record.
Thank you. I am not sure how it works, will check.
if you need to use SSRS I would look to apply a filter after you retrieve the dataset, I know it's not ideal but with FetchXML (afaik) is not possible to limit the related records
Thank you for the reply. Need in FetchXml as we need to use in SSRS report.
I am not aware of doing it with FetchXML but it can be done with Web API if you apply the $top to the expand with a specific syntax (; instead of &)
the query is something like this:
/api/data/v9.2/accounts?$select=name&$expand=contact_customer_accounts($select=contactid,fullname;$top=1)
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156