Skip to content

Dynamics 365 Default Customer Field

As of January 2022, in Dynamics 365 Customer Engagement, the customer field allows for B2B and B2C customer types. For B2B customers, defaulting the customer field to both accounts and contact doesn’t make sense. There is no UI customization to default the lookup to accounts only. The following JavaScript function sets the customer field to accounts only.

The following screen shot shows the default out of the box behavior:

To default to accounts only. Create a web resource with the following code:

function FormLoad(executionContext) {
  try {
      var formContext = executionContext.getFormContext();
      formContext.getControl("customerid").setEntityTypes(["account"]);
  }
  catch (e) {
       Xrm.Navigation.openAlertDialog({ text: "Error: " + e.message });
  }
}

Update the onload event to reference the JavaScript code above:

The updated form now only accepts accounts.

I hope that you found this post helpful.

No comment yet, add your voice below!


Add a Comment

Your email address will not be published. Required fields are marked *