Set Regarding and Party list field in Dynamics 365 CRM UCI using Open Entity Form

By | August 30, 2019

Introduction

With the release of Dynamics 365 V9.0 many client API has been changed. The list of the client API in which Dynamics 365 v9.0 is supported is available here.

In this blog, we will see how to set regarding and party list field using open entity form in UCI.

We had a requirement to open the new entity form and populate the regarding and party list field of  activity entity. We tried the standard way to open the entity form with required fields need set using client API as given below:

var parameters = {};

var entityFormOption = {};

//Set the reqarding field value
parameters[“pId”] = “2878282E-94D6-E111-9B1D-00155D9D700B”;
parameters[“pName”] = “Contoso”;
parameters[“pType”] = 1;   //object type code

//set required attendees

parameters[“partyid”] = “2878282E-94D6-E111-9B1D-00155D9D700B”;

parameters[“partyname”] = “Contoso”;

parameters[“partytype”] = 1; //object type code

//open new record

entityFormOption.entityName = “appointment”;
entityFormOption.entityId = null;
entityFormOption.openInNewWindow = true;

//open the entity record
Xrm.Navigation.openForm(entityFormOption, parameters, successCallback, errorCallback);

However, the above code did not populate the regarding and party list field of activity entity.

We tried to find another way to set these fields. However, the fields were not populated while opening the entity form using Xrm.Utility.openForm in UCI.

Finally, we found a way to populate the values for these fields while opening the entity form in UCI. Given below is the code which can be used for the same:

var parameters = {};

//Set regarding field

parameters[“regardingobjectid”] = “2312bf7b-c57b-e911-a99a-00224800c5e8”;

parameters[“regardingobjectidname”] = ” Contoso”;

parameters[“regardingobjectidtype”] = “account”;   //logical name

//set partylist field

var value = new Array();
value[0] = new Object();
value[0].id = “34cf15jk-445a-e843-80bb-a5334caf8811”;
value[0].name = “richard smith”;
value[0].entityType = “contact”;

parameters[“requiredattendees”] = value; //”Required” field

//open new appointment record

entityFormOption.entityName =”appointment”;

entityFormOption.entityId = null;

entityFormOption.openInNewWindow = true;

entityFormOption.cmdbar = true;

//open the entity record

Xrm.Navigation.openForm(entityFormOption, parameters, successCallback, errorCallback);

Conclusion

By using the above code, we can set the regarding and party list field while opening any entity form using client API in Dynamics 365 UCI.

Free 70% of storage space in CRM with Attachment Management Apps!

Attach2Dynamics – Store and manage documents/attachments in cloud storage of your choice – SharePoint, Dropbox or Azure Blob Storage from within Dynamics 365 CRM.
SharePoint Security Sync – Robust and secure solution to integrate Dynamics 365 CRM and SharePoint Security Sync thereby ensuring secure access to confidential documents stored in SharePoint.

5 thoughts on “Set Regarding and Party list field in Dynamics 365 CRM UCI using Open Entity Form

  1. Gul zaman Khan

    Very helpfull my problem is solved after following this

  2. guillermo

    Is it possible to set a multi lookup field for any entity form?

    1. Inogic

      Yes, it is possible to set a multi lookup field. You need to pass array of party list. Below is the working code,

      var parameters = {};

      //Set regarding field

      parameters[‘regardingobjectid’] = ‘8ebadbc2-f9da-ea11-a814-000d3a0a82a5’;

      parameters[‘regardingobjectidname’] = ‘A. Datum Corporation (sample)’;

      parameters[‘regardingobjectidtype’] = ‘account’; //logical name

      //set multiple values in requirred attendees

      var value = new Array();
      value[0] = new Object();
      value[0].id = ‘33324cf1-e4e2-ea11-a814-000d3af26e41’;
      value[0].name = ‘Adam K’;
      value[0].entityType = ‘contact’;

      value[1] = new Object();
      value[1].id = ’20ba2a4f-e2e2-ea11-a814-000d3af26e41′;
      value[1].name = ‘Joe T’;
      value[1].entityType = ‘contact’;

      parameters[‘requiredattendees’] = value; //”Required” field

      //open new appointment record

      entityFormOption.entityName =’appointment’;

      entityFormOption.entityId = null;

      entityFormOption.openInNewWindow = true;

      entityFormOption.cmdbar = true;

      //open the entity record

      Xrm.Navigation.openForm(entityFormOption, parameters, function(){}, function(){});

      Hope this helps.

      Thanks!

  3. kalpesh Joshi

    How can we change Views inside “Change View” button in party list?

    1. Inogic

      This blog explores to set the Regarding and Party-list field while opening any entity form.

      You can use “setDefaultView” client API to set the view of lookup.

      It can also be used to set the view of a particular entity in the party list.

      e.g. formContext.getControl(“to”).setDefaultView(“{00000000-0000-0000-00AA-000010001003}”);

      Link for your reference – https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/setdefaultview

      Hope this helps.

      Thanks!

Comments are closed.