Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Plugin lookup

Posted on by 1,695

I have a plugin which reads a file and extracts data from several crm entities to create a new record in a third entity

when I query the lookup field in entity a, I get a string of the id back into the plugin, how do I convert this back to a entity reference to insert in to the new record in entity B

I have tried

Dim LicenceGuid As New Guid

Guid.TryParse(ImportReturnElements(2).ToString, LicenceGuid)

but that throes up an exception

 

 

*This post is locked for comments

  • Verified answer
    abvogel Profile Picture
    abvogel 150 on at
    RE: Plugin lookup

    TryParse should be able to parse it and set the value to LicenseGuid. Can you confirm that "ImportReturnElements(2).ToString" returns a valid string? Should it be .ToString()?

  • Verified answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: Plugin lookup

    EntityEeference er = new EntityEeference("entitylogicalname",new Guid("string guid"));

  • Suggested answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: Plugin lookup

    Hi PeteN,

    Please look at the following example, I think this is what you need to do:

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

    It shows very similar examples of connecting products to the opportunity.

    // Create another catalog product and override the list price

    OpportunityProduct catalogProductPriceOverride = new OpportunityProduct

    {

         OpportunityId = new EntityReference(Opportunity.EntityLogicalName,

           _opportunityId),

         ProductId = new EntityReference(Product.EntityLogicalName,

           _product2Id),

         UoMId = new EntityReference(UoM.EntityLogicalName, _defaultUnitId),

         Quantity = 3,

         Tax = new Money(2.88m),

         IsPriceOverridden = true,

         PricePerUnit = new Money(12)

    };

    Hope this helps.

    Thanks,

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans