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)

Using multiple entities in plug-in code?

(0) ShareShare
ReportReport
Posted on by

Hello,

As much as I understand for a plug-in is only possible to use the attributes of the entity that was registered. My question refers to if is possible to use not only attributes of the entity that was registered, also take take from any other entity?

I need it, cause I require to validate some data against data from another entity. If is possible, how can I do that?

Thank you very much,

Greetings.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

    yes.. you need to retrieve another entity data in plugin.

  • Suggested answer
    Brad Sprigg Profile Picture
    985 on at

    Hi Ken

    Yes, typically you would use the Retrieve or RetrieveMultiple message to gather the records you need. See link below from the SDK.

    msdn.microsoft.com/.../microsoft.xrm.sdk.iorganizationservice.retrieve.aspx

    Regards

    Brad

  • Verified answer
    nghieppham Profile Picture
    4,755 on at

    Hi Ken15,

    You can do that. If this entity is EntityReference and it is presented, you can use context.target["RelateEntities"] to get the value. Other way, you can retrieve by condition of your triggered entity.

    Regards,

  • Verified answer
    Community Member Profile Picture
    on at

    I discovered that is possible to use all the entities that are currently linked to the entity that the plug-in is referring.

    I could do this by using this code:

    EntityReference entRefMyEntity = null;
                            try
                            {
                                    if (entPartner.Contains("NameOfAttribute"))
                                    {
                                        entRefMyEntity = entPartner.GetAttributeValue<EntityReference>("ownerid");
                                        Entity entMyRelatedEntity = PluginHelper.GetContact(service, entRefMyEntity);
    
                                        if (entRefMyEntity .Contains("MyCRMInput"))
                                        {
                                            string myvalue = entMyRelatedEntity.GetAttributeValue<string>("NameOfAttribute");
                                        }
                                    }
                            }
                            catch (Exception ex)
                            {
                                myTrace.WriteLine("Error: " + ex.Message);
                            }
    


    Thanks a lot,

    Regards.

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