Using ActivityParty in CRM 2011

05Jun11

I was writing some client code recently when I wanted to add a customer reference to a CRM campaignresponse entity instance. Using a simple EntityReference was giving me errors, so I looked to see what the data type was in CRM. Looking in the customisations screen, the type was ‘Party List’. The CRM SDK docs say that we should be able to use ActivityParty[] or EntityCollection for the field value.

The only info on ActivityParty that I found was for CRM4. Through trial and error I arrived at the following code:

Entity customer = new Entity("activityparty");
customer["partyid" ]= new EntityReference( "contact", in_contactID );
campaignResponse["customer"] = new EntityCollection( new List(){ customer } );

So what I had to do was create a list of entities that had an EntityReference field set that pointed to the contact. You cannot set the EntityReference directly on the campaignresponse, it is expecting an EntityCollection. Hopefully this saves you some time.

Advertisements


9 Responses to “Using ActivityParty in CRM 2011”

  1. 1 Owen

    Great post, this not only saved some time, it probably saved my job!

    • 2 newcome

      Thanks, glad it helped you – can’t get a much better endorsement than that.

  2. 3 Jose

    Thanks this also saved me a lot of time .

    • 4 Bryan Freeman

      Great post! This works perfectly and saved me a lot of trouble.

      Bryan Freeman
      EMC

  3. 5 Jerry

    Thank you! the sdk is so well documented (lol) that we have to resort to nugget hunting,

    Thanks again for sharing.

  4. Thanks! this post saved me lots of time!

    tweak: new EntityCollection(new List() { customer})

  5. 7 thoughtstufftom

    Just another +1 for really helpful post. Have wrestled with this for a couple of hours now, especially as I am new to CRM development. Thanks for the info!

  6. 8 anosy

    tnx, your post helped me to understand:

    // Create an Activity Party record for each Contact.
    var activityParty1 = new ActivityParty
    {
    PartyId = new EntityReference(Contact.EntityLogicalName, contacts[0].ContactId.Value),
    };

    http://msdn.microsoft.com/en-us/library/gg334289.aspx

  7. 9 Haris

    Ah…Thanks alot. saved me a lot of time and effort INDEED!!


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: