I am using Xrm.Utility.openEntityForm
to clone a record. I have a group of attributes I need to copy over to the new form when I call openEntityForm
. You do this by passing in a parameters
object that is filled with the values of the attributes on the original form.
My question is: How do I pass the value of a lookup field as a parameter in the parameters object? I have a lookup field named "Department" -- I get the original value like this:
var department = parent.Xrm.Page.getAttribute("new_departmentid").getValue();
To set the value of the field on the cloned record, I initially create a parameter object -- var parameters = {};
-- and I set the value for the lookup field like this --
parameters["new_departmentid"] = department[0].id;
The parameters object gets passed to the openEntityForm method. This works to set the value of the new form's Department field, BUT the field reads "(No Name)".
I tried to do something like this:
parameters["new_departmentid"] = {
id: department[0].id,
name: department[0].name,
entityType: "new_department"
};
But that did not work, and I got errors saying parameter["new_departmentid"]
expects a data type of "UniqueId".
How do I pull along the name to correctly populate the lookup field using this method? Thanks for any help.