To set a lookup field value, you need 3 parameters.
- Id of the lookup record
- name of the lookup record
- entity name of the lookup entity
Here is how to use these values to set an account lookup field.
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = myAccountId;
lookupValue[0].name = myAccountName;
lookupValue[0].entityType = "account";
Xrm.Page.getAttribute("mylookupfield").setValue(lookupValue);
Can I use this to create a “None” value?
LikeLike
Hi, didn’t get the question sorry
LikeLike
My apologies. We have a lookup field of users, and there is a requirement to include a None option. Can I use this script to achieve the requirement?
LikeLike
Hi, I’m afraid you can’t do that. You can’t put a placeholder to the lookup field. But as a workaround you can create your own pcf contro. You can make it look like lookup. Then you can add a none placeholder. Check the pcf controls
LikeLike
Good to know. Many thanks 🙂
LikeLike