We will learn to hide the +New button from a Lookup field in Dynamics 365 / Model-Driven App. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in the field of Power Platform.
Why do we need to hide or remove the +New button from a lookup?
Consider a requirement where you need to remove the +New button for limiting the system users from creating a new record in the lookup’s target table.
This requirement can be achieved from two different ways:
Approach 1 –Edit the Security Role and remove the “CREATE” privilege from the Lookup’s target entity.
Approach 2 –Customize the Lookup component XML from backend for hiding / removing the +New button.
We learn to remove the +New button by customizing the XML as shown below.
Removing the +New button from a Lookup by customizing the solution XML
Follow the below steps for removing the button from a Lookup field:
Step 1 – Creating & Exporting a Solution
- Open the Power Apps Studio (https://make.powerapps.com/).
- Navigate to Solutions and create a new un-managed solution.
- Add an Entity / Table form where the lookup field is residing within this newly created un-managed solution.
- Export the solution as an “Un-Managed” solution.
Step 2 – Customizing the Solution XML & Re-Import the Solution
- Navigate to the folder where the newly created un-managed solution is exported. Un-Zip the solution as shown below.
- Open the file “customizations.xml” in Visual Studio as shown below.
- Within the Customization XML, navigate to the XML tag where the lookup field resides. In this scenario, we will be searching the name of our lookup field which is “cc_contact” in the Customization.XML file.
- Now, add an addition XML Tag specifying the parameter “IsInlineNewEnabled” as false as given below in the XML Code.
<parameters> <IsInlineNewEnabled>false</IsInlineNewEnabled> </parameters>
- Once the XML is modified, save the file, compress the file to a new solution Zip and re-import the solution into the Model-Driven App / Dynamics 365 CRM.
- After the successful re-import, validate that the “+New” button is removed from the lookup field as shown below.