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

Meta Data Using WebApiRequest

Sample CRUD Operations Using C# in MSCRM

Basic Plugin Code in D365 using C#