softwaremom

Just another WordPress.com site

Tag Archives: Dynamics CRM SDK

How to set the “From” attribute for a PhoneCall entity using Dynamics CRM 2013 SDK

In working on my Incident Management POC, I’ve found that I need to set the phone call’s “From” attribute to a contact programatically and I had some trouble finding out how to do that. ┬áThe following is the definition of the “PhoneCall.From” property in C#:

public System.Collections.Generic.IEnumerable<UIM.ActivityParty> From

I search online for code samples and couldn’t find one. ┬áThis is what works for me to set the “From” attribute for a PhoneCall entity with phonecallId, with a contactId, after a lot of try/error:

var myPhoneCall = myContext.PhoneCallSet.Where(p=>p.Id == phonecallId).Single();

ActivityParty actvityParty = new ActivityParty()
{
ActivityId = new EntityReference(PhoneCall.EntityLogicalName, phonecallId),
PartyId = new EntityReference(Contact.EntityLogicalName, contactId)
};
myPhoneCall.Id = phonecallId;
myPhoneCall.From = new List<UIM.ActivityParty>() { actvityParty };
myOrgService.Update(myPhoneCall);

Advertisements