softwaremom

Just another WordPress.com site

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: