Get PartyList lookup field in Email/Activities entity update partyid record

Get the partylist lookup value and check the lookup value is contact and update the contact  

Entity fromActivityParty = targetEntity.GetAttributeValue<EntityCollection>("from").Entities

                .Where(x => x.GetAttributeValue<EntityReference>("partyid")?.LogicalName == "contact")

                .FirstOrDefault();


         if (fromActivityParty == null) return;


         EntityReference contactReference = fromActivityParty.GetAttributeValue<EntityReference>("partyid");

Entity contact = new Entity("contact", contactReference.Id);

contact["fullname"]= "ApyCRM";

service.Update(contact);


Comments

Popular posts from this blog

Create a Trigger and Journey

Calling Action using javascript with web api request in mscrm

Append and Append To difference in Microsoft Dynamic CRM