I’m making a button on PhoneCall ribbon that creates follow up call. I’ve tried to do this with javascript, with XrmServiceToolkit. Looks like I can’t do it at all with SOAP end point and doing it with REST is some what tricky.
How do I copy to and from fields to a new activity?
Update Originally I tried using XrmServiceToolkit javascript library, but switched to C# for copying fields, following Peter’s answer.
Still, no result. I do it this way:
EntityCollection toCollection = new EntityCollection();
foreach (var activityParty in ((EntityCollection)previousActivity["to"]).Entities)
{
Entity newActivityParty = new Entity(ActivityParty.EntityLogicalName);
newActivityParty["activityid"] = new EntityReference(context.PrimaryEntityName, context.PrimaryEntityId);
newActivityParty["partyid"] = activityParty["partyid"];
newActivityParty["participationtypemask"] = new OptionSetValue(2);//activityParty["participationtypemask"];
//service.Create(newActivityParty);
toCollection.Entities.Add(newActivityParty);
}
entity["to"] = toCollection;
What’s the right way to do it?
Ended up doing it with JavaScript, after all: