JavaScript – Set Activity Party

I seem to have a theme of JavaScript posts this week! Maybe because I’m having “fun” doing some coding ….. anyway here is a simple snippet you might find useful.

This function can be used to set an activity party field. Such as “to” or “from” on a phone call. Simply pass in the field you want to set. Say “to”. The id and name of the contact (or other entity) you want to assign, plus the entity type. Say “contact”.

// *** Function to set a party list
function setToPartyList(fieldName, id, name, entityType) {
  var party = Xrm.Page.getAttribute(fieldName);

  // Create new array
  var partlist = new Array();
  partlist[0] = new Object();

  partlist[0].id = id;
  partlist[0].name = name;
  partlist[0].entityType = entityType;

  // Set array value
  party.setValue(partlist);

};

5 thoughts on “JavaScript – Set Activity Party

  1. Pingback: JavaScript – Get Activity Party List | Microsoft Dynamics CRM and Unified Service Desk

  2. Pingback: JavaScript – Get Activity Party List - Microsoft Dynamics CRM Community

  3. Pingback: Happy New Year – Pop Pickers | Microsoft Dynamics CRM and Unified Service Desk

  4. Hi Neil, i am setting custom entity vendor in to party list but it give me error vendor entity not supported.
    if i set lead,contact,account,or user entity then it worked but custom entity not supported.
    could you please suggest.

    Like

Leave a Reply to Neil Parkhurst Cancel 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 )

Facebook photo

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

Connecting to %s