Thursday 20 July 2023

Hide New... button on lookup controls in model-driven apps

 The 'New ...' button is shown upon opening the lookup search dialog whenever the logged in user has at least user create privilege on a dataverse table. We recently had a requirement to prevent users from creating a new record from the lookup. This was required only on a specific form. The users should otherwise be able to create the record from other areas of the model driven app.


Unfortunately, there is no way of hiding the out of the box button from the user interface via the form editor and to remove the create privilege did not suit our purpose:


Luckily there is an option within the form XML that helps us to achieve the desired outcome. Adding the tag <IsInlineNewEnabled>false</IsInlineNewEnabled>, will remove the button for all users no matter what their privileges allow. This tag is usually not present on the form xml. This solution is supported and works for current Power Platform model-driven apps. Should work for on premise as well but haven’t tried it.


Steps:

  1. Create an unmanaged solution containing only the required form.

  2. Locate the lookup control based on its schema name in customizations.xml

  3. Add IsInlineNewEnabled tag to control's parameters collection

  4. Zip the contents of the extracted folder including your modified customizations.xml

  5. Import the newly created solution zip file and publish all changes.

  6. Verify that the button is not shown.

Sample schema of the lookup is as shown below (Parameters of your lookup instance might vary). The new tag is highlighted:



If all goes as expected, then the result should be as shown below:


Hide New... button on lookup controls in model-driven apps

  The 'New ...' button is shown upon opening the lookup search dialog whenever the logged in user has at least user create privileg...