In a Model-Driven App, a lookup field is a special type of field that allows you to reference records from another entity or table. Essentially, it enables linking data across different entities or tables.
Typically, lookup fields include a “+ New” option, which lets users create a new record in the related table and automatically associate it with the current record.
What happens if a user tries to create a new record from a lookup field, but they don’t have access to the related entity?
In such cases, the best approach is to prevent the user from creating a new record directly from the lookup field by hiding the “+ New” button.
There are two common ways to restrict users from creating new records via lookup fields:
- Remove the Create privilege for the target entity in the user’s security role.
- Hide the “+ New” button in the lookup field by modifying the form XML using tools like FormXml Manager.
Removing the Create Privilege for a Target Entity
To prevent users from creating new records for a specific entity, follow these steps to remove the Create privilege:
- Navigate to Advanced Settings in your environment.
- Under Power Platform Environment Settings, Go to System > Security
- Open Security Roles, then select the specific role you want to modify
- Under the Core Records or Custom Entities tab, locate the target entity
- Remove the Create privilege for that entity.
- Click Save and Close to apply the changes.
Hiding the “+ New” Button Using XrmToolBox and FormXML Editor
To hide the “+ New” button in a lookup field using the XrmToolBox, follow these steps:
- Install XrmToolBox if you haven’t already
- Connect to your organization:
- Launch XrmToolBox
- Enter your credentials and select Office 365 as the deployment type
- Once connected, go to Tools and search for FormXmlManager
- Install the FormXML Manager Tool if it’s not already installed
- Reconnect to your organization and select the appropriate environment
- Click Load Entities to retrieve the list of all entities.
- Select the desired entity, then choose the relevant form from the right-hand panel
- Click Edit Form XML to begin modifying the form and hide the “+ New” button
- Insert the following line into the parameters section of the lookup field:
<parameters> <IsInlineNewEnabled>false</IsInlineNewEnabled> </parameters> |
- Update and publish the XML.
- Verify the field in the UI—if successful, the ‘New’ button will be hidden for the lookup field (refresh cache if required Ctrl+F5).
YAY! 😊