web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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 397

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

I have the same question (0)
  • Verified answer
    Tomas Prokop Profile Picture
    590 on at

    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"];
    


  • Srini20 Profile Picture
    397 on at

    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
    590 on at

    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

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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
    ashlega Profile Picture
    34,477 on at

    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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans