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;
}
*This post is locked for comments