Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

ReferencedEntity Value - Modifiedby value in plug-in

(0) ShareShare
ReportReport
Posted on by 395

Hi,

Looking for an answer to make another call to just to retrieve the name.

I need the Modified by value in plug-in. When i verified the advanced find fetchxml i get the Modified by value(User Name) as string but when i am trying in Plug-in i get the Guid. I need the opportunity modified by user name. Do i need to make another call to SystemUser entity to get the name? In c# plug-in modified by value comes as Guid. I am looking for an option whether i can get the user name text without making another call to SystemUser entity either using ReferencedEntity or any other way? 

*This post is locked for comments

  • Verified answer
    ashlega Profile Picture
    ashlega 34,477 on at
    RE: ReferencedEntity Value - Modifiedby value in plug-in

    When it's coming from the client, Dynamics tends to ignore "names" (there is no value in having those names, usually, since all references are, really, about ID-s). I'd just query CRM in your plugin to get the name.

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: ReferencedEntity Value - Modifiedby value in plug-in

    Hello,

    Try to retrieve using "modifiedbyyominame" attribute , but I am not sure seems without access system user table you can not get the modified by user name in the plugin.

    As an alternate if you can create one additional text field and in client side on save you assign the current user name (Xrm.Page.context.getUserName();) to the text field . From plugin you can directly get the user name from your text field.

  • Verified answer
    Tomas Prokop Profile Picture
    Tomas Prokop 590 on at
    RE: ReferencedEntity Value - Modifiedby value in plug-in

    I don't think you will find username in context variables. If you try to retrieve it using organization service it will return a cached value if the attribute will have been already accessed in the transaction.

    In case you want to get Full Name attribute you can use the Name property of EntityReference class as mentioned above.

    2018_2D00_05_2D00_09_5F00_20_2D00_56_2D00_10.png

  • Srini20 Profile Picture
    Srini20 395 on at
    RE: ReferencedEntity Value - Modifiedby value in plug-in

    Thanks Tomas Prokop. Above code also makes an additional call. I am on Opportunity entity and want to know the modified by user name. I can make another call and retrieve that but i am looking for some thing that directly can grab the name similar like linked entity. I have already a Target object as Opportunity as i am in Opportunity plug-in. Is there any way without making a Retrieve call we can grab the name of the opportunity owner name?

  • Verified answer
    Tomas Prokop Profile Picture
    Tomas Prokop 590 on at
    RE: ReferencedEntity Value - Modifiedby value in plug-in

    Hi,

    there is a chance that the EntityReference instance has also Name property populated which is a primary attribute of the referenced entity. 

    2018_2D00_05_2D00_09_5F00_20_2D00_16_2D00_38.png

    Unfortunately systemuser entity uses Full Name as the primary attribute.

    2018_2D00_05_2D00_09_5F00_20_2D00_16_2D00_38.png

    If you want to retrieve the username you have to make a call to the organization service (late bound style). You should specify only fields you want to retrieve in ColumnSet:

    //Create service factory
    var serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
    
    // Create Organization service
    _organizationService = serviceFactory.CreateOrganizationService(_context.UserId);
    
    
    var userRecord = _organizationService.Retrieve(userReference.LogicalName, userReference.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet("domainname"));
    
    var userName = userRecord["domainname"];
    


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,399 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans