Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Hot get Aggregate attribute Id and Name in plugin

(0) ShareShare
ReportReport
Posted on by 383

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

pastedimage1681458958559v5.png

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.

pastedimage1681458877203v4.png

  • Suggested answer
    Ray Profile Picture
    Ray 1,480 on at
    RE: Hot get Aggregate attribute Id and Name in plugin

    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.

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans