How to Set Lookup Field Value Using JavaScript -Dynamics 365

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";


5 thoughts on “How to Set Lookup Field Value Using JavaScript -Dynamics 365

      1. 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?


      2. 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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s