JavaScript – Get Activity Party List

Following on from an earlier post that explained how to set an activity party list, here is some JavaScript to show how to get an activity party list.

getParty("to");



function getParty(fieldName) {

  var party = Xrm.Page.getAttribute(fieldName);
  var members = party.getValue();

  for (var i = 0; i < members.length; i++) {
	// Contact
	if (members[i].type == 2) {
	  alert("Contact Id-" + members[i].id + " Name-" + members[i].name);
	}
	// Account
	if (members[i].type == 1) {
   	  alert("Account Id-" + members[i].id + " Name-" + members[i].name);
	}
	// Lead
	if (members[i].type == 4) {
	  alert("Lead Id-" + members[i].id + " Name-" + members[i].name);
	}
	// User
	if (members[i].type == 8) {
	  alert("User Id-" + members[i].id + " Name-" + members[i].name);
	}

  }

}

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