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.