Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Update Email Activity (Field type: Party List) using asynchronous plugin.

$
0
0

I am trying to update the To, Sender & Cc fields of an email activity using a plugin. But I am getting an error says something like this "cannot update activity when email is in draft state". Also I need some assistance on how to update field of type 'party list'. 

I have attached a method which essentially updates the Email entity which is passed to the plugin via IServideProvider. 

private void UpdateActivity(ContactLookupResult result)
{

    Entity senderActParty = new Entity("activityparty");
    if (result.SenderContactId.Value == Guid.Empty)
    {
         senderActParty["addressused"] = result.SenderContactId.Key;
    }
   else
    {
     senderActParty["partyid"] = new EntityReference("contact", result.SenderContactId.Value);
    }
   currentEntity["from"] = senderActParty;


   EntityCollection recipientCollection = new EntityCollection();
   foreach (KeyValuePair<string,Guid> item in result.RecipientsId)
   {
       Entity entity = new Entity("activityparty");
       if (item.Value == Guid.Empty)  // item.value is the contact Id
       {
        entity["addressused"] = item.Key;
       }
      else
      {
        entity["partyid"] = new EntityReference("contact", item.Value);
      }
      recipientCollection.Entities.Add(entity);
    }
    currentEntity["to"] = recipientCollection;

}


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>