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
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()?
EntityEeference er = new EntityEeference("entitylogicalname",new Guid("string guid"));
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,
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156