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

Basic Plugin Code in D365 using C#

CURD (Create, Update, Retrieve and Delete) Operation in D365 using Power Shell Script

Meta Data Using WebApiRequest