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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

how to get current record owner id in plugin

(0) ShareShare
ReportReport
Posted on by 483

Hello,

Iam trying to get current record owner id and got query result from query expression by passing colum ownerid but when trying to convert it to GUID getting with the following . pls suggest how to convert to guid

 

Guid OwnerID;

OwnerID = ((EntityReference)(Opportunityrecord.Attributes["ownerid"])).Id;

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Preeti Sharma Profile Picture
    2,678 on at

    Hi dKrishna,

    Code to retrieve any lookup field is same as you defined above.

    Are you getting any error?

    Thanks

  • Suggested answer
    Jan Gracelin Jeno Profile Picture
    150 on at

    Hi,

    this is correct.check whether the Opportunityrecord has "ownerid".

  • naZir Profile Picture
    850 on at

    Your Code is looking fine. Not sure try this.Your OwnerID is GUID Type and the result you are getting is entityrefrence type.  so do change accordingly and try.

  • Verified answer
    Michel Gueli Profile Picture
    982 on at

    Opportunityrecord.GetAttributeValue<EntityReference>("ownerid").Id

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

    Try with this-              

    foreach (var targetEntity in ec.Entities){

      Guid ownerid = (targetEntity["ownerid"] as EntityReference).Id;

    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans