Sometimes when establishing relationships between an existing entity such as Account and some new entity that has lookup fields which also point to the Account entity, we get unwanted and forced data mappings. These mappings cannot be deleted so we need to use Javascript to null these fields.

The script below first of all detects the mode of the form because we would only want to null the lookup fields the first time the form is opened, and not subsequently.

The function “Xrm.Page.ui.getFormType();” returns a number based on the mode of the form, if it is in create mode then the function returns a 1.

Here is the full script which includes all the form mode types for future reference:

Start a Project With Us

Submit your email below to get in touch with our team.