Get and Set ‘Partylist’ fields using Jscript

This was a recent query asked to me. Adding a solution done by my old colleague Rajeev here:

Rajeev Pentyala - Dynamics 365 Blog

If you observe “Required” lookup field on an ‘Appointment’ form, you can choose more than one Accounts or Contacts or Users.

Though it looks like a normal lookup field actually it’s a field of type ‘Party list’.

Party List :-

  • Party List is a data type in CRM, using which you can set more than one records of an entity for a single field.
  • Part List type field, renders as Lookup on the form, but it works as multi select lookup.
  • We can’t create a custom party list fields.

For example,

  • In the ‘Appointment’ entity field “Required” is a ‘Party List’ type
  • We can select multiple records of different type (i.e., Accounts, Users, Contacts…)

Partylist Type

Below is Jscript to Get or Set ‘Partylist’

function getPartyList() {

var partyRequired = Xrm.Page.getAttribute(“requiredattendees”);

var attendees = party.getValue();

for (var indxAttendees = 0; indxAttendees < attendees.length; indxAttendees++) {

// User

if (attendees[indxAttendees].type == 8) {

alert(“Attendee is User; Id…

View original post 93 more words

{DYNAMICS CRM 2015}Calculate ROLLUP FIELD PROGRAMATICALLY

Retrieve a calculated rollup field value immediately

Rollup attributes support a CalculateRollupField message that developers can use to calculate a rollup attribute value on demand. The request and response, along with the members, are shown in the following table.

Request/Response
Members

CalculateRollupFieldRequest

Target: EntityReference for the record.

FieldName: String representing the logical name of the attribute.

CalculateRollupFieldResponse

Entity: Entity containing the rollup attribute and the supporting <attribute SchemaName>_Date and <attribute SchemaName>_State attributes.

This message is a synchronous operation for just the attribute identified in the request. If the value of that record is included as part of other rollup fields, the values of those fields won’t take the possible value change caused by calling this method into consideration until the regularly scheduled asynchronous jobs that perform those calculations occur.

Source: Click here

Hope it helps!