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)

get the attributes from one entity through plugin

(0) ShareShare
ReportReport
Posted on by 2,510

Hi, I am creating a simple plugin, how can I get the attributes from one entity, and the record ID as well. For example, I want to get the current contact ID on the contact form.

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Thomas David Dayman Profile Picture
    11,323 on at

    To get the ID of the record you are running the plugin on:

    entity = (Entity)context.InputParameters["Target"];
    
    Guid contactid = entity.Id;


    To get an attribute of the record you are running the plugin on (You will have to change the data type depending on the field you want to get):

    var fullname = ((string)(entity.Attributes[fullname]));
  • Verified answer
    Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    You can obtain the record id (contactid) from Target of the input parameters collection.

    For example (update message):

    // The InputParameters collection contains all the data passed in the message request.
    if (context.InputParameters.Contains("Target") &&
        context.InputParameters["Target"] is Entity)
    {
        // Obtain the target entity from the input parameters.
        Entity entity = (Entity)context.InputParameters["Target"];
    


    Here you can get the id from entity.Id

    https://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.entity.aspx

    Please refer the following:

    [View:https://msdn.microsoft.com/en-us/library/gg309673.aspx:750:50]

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