Prevent New... button on lookup controls in model-driven apps
As soon as a user has at least user create
privilege on a Dataverse table a 'New ...' button is shown upon opening the lookup search dialog. This sometimes-handy feature might be a source of inconsistency for the user experience and might lead to wrong data entry as records might be created at times when only existing ones should be used, depending on your business process.
Issue
Sadly, 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
might not be a feasible option.
Solution
Luckily there is an option within the form XML schema that allows exactly the desired behavior. Adding the tag <IsInlineNewEnabled>false</IsInlineNewEnabled>
(usually this tag is not present in formXml), will remove the button for all users no matter what their privileges allow. The provided solution is supported and works for Dynamics Customer Engagement on-premises as well as current Power Platform model-driven apps.
Procedure
- Create an unmanaged solution containing only the form
- Export the solution zip file and extract it to disk
- Locate the lookup control based on its schema name in
customizations.xml
- Add
IsInlineNewEnabled
tag to control's parameters collection - Zip the contents of the extracted folder including your modified
customizations.xml
- Import the newly created solution zip file and publish all changes
- Verify that the button is gone now
The parameters of your lookup instance might not match the ones shown here. Or in case you did not set any additional parameters via form editor might not even be present at all. In that case just add a parameters tag including the tag IsInlineNewEnabled
.
<control id="new_contractid" classid="{270BD3DB-D9AF-4782-9025-509E298DEC0A}" datafieldname="new_contractid" uniqueid="{8dcea322-b6ee-5a9b-a429-b47dc98d75a7}">
<parameters>
<AutoResolve>true</AutoResolve>
<DisableMru>false</DisableMru>
<DisableQuickFind>false</DisableQuickFind>
<DisableViewPicker>false</DisableViewPicker>
<AllowFilterOff>false</AllowFilterOff>
<IsInlineNewEnabled>false</IsInlineNewEnabled>
</parameters>
</control>
Result
As a result, the 'New...' button is gone.
References
The lookup control schema verifies that this is a valid modification of the formXML and the customization guidelines state that Modifying the customization.xml is a valid act.
<!-- Parameters for the lookup control -->
<xs:choice minOccurs="1"
maxOccurs="unbounded">
<xs:element name="DefaultViewId"
type="FormGuidType"
minOccurs="0"
maxOccurs="1" />
<xs:element name="FilterRelationshipName"
type="xs:string"
minOccurs="0"
maxOccurs="1" />
<xs:element name="DependentAttributeName"
type="xs:string"
minOccurs="0"
maxOccurs="1" />
<xs:element name="DependentAttributeType"
type="xs:string"
minOccurs="0"
maxOccurs="1" />
<xs:element name="AutoResolve"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="ResolveEmailAddress"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="DefaultViewReadOnly"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="ViewPickerReadOnly"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="AllowFilterOff"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="DisableMru"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="DisableQuickFind"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="DisableViewPicker"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="AvailableViewIds"
type="xs:string"
minOccurs="0"
maxOccurs="1" />
<xs:element name="EntityLogicalName"
type="xs:string"
minOccurs="0"
maxOccurs="1" />
<xs:element name="IsInlineNewEnabled"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="InlineViewIds"
type="xs:string"
minOccurs="0"
maxOccurs="1" />
<xs:element name="UnboundLookupTypes"
type="xs:string"
minOccurs="0"
maxOccurs="1" />
<xs:element name="UnboundLookupBrowse"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
<xs:element name="UnboundLookupControlType"
type="xs:string"
minOccurs="0"
maxOccurs="1" />
<xs:element name="ShowAsBreadcrumbControl"
type="xs:boolean"
minOccurs="0"
maxOccurs="1" />
</xs:choice>