Announcements
Hi,
I have a c# plugin, where I am using an aggregate fetch, and I have applied the groupBy property to a lookup attribute, now I need to retrieve the Id and Name of the group by records.
My fetch
In this SS, I have highlighted the line number 103 attribute, which is the lookup attribute and Now I need to retrieve this attribute id and name.
I have run this fetch through the fetch xml tester, you can see the SS below, here I am able to seen both values "Id" and "RecordsName". So like this I need to get the Id's and records name through my plugin code.
Hi Himanshu,
Here is a sample code for you:
var fetchXml = @" "; var results = OrgService.RetrieveMultiple(new FetchExpression(fetchXml)); if (results.Entities.Any()) { // use the attribute alias to get the attribute var owerAlias = results.Entities.First().GetAttributeValue("aliasownerid"); if(owerAlias != null && owerAlias.Value != null) { // convert AliasedValue to actual attribute type var owerRef = (EntityReference)owerAlias.Value; var id = owerRef.Id; var name = owerRef.Name; } }
You can replace the fetchXml with yours and follow the other code to get the attribute you want.
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... 290,186 Super User 2024 Season 2
Martin Dráb 227,996 Super User 2024 Season 2
nmaenpaa 101,148