65.9K
CodeProject is changing. Read more.
Home

Restrict users from using the Quick Create option (plus sign) in the top navigation of Dynamics CRM 365.

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Oct 13, 2024

CPOL
viewsIcon

2037

Remove an Entity from top bar fast Quick Create in Microsoft Dynamics 365

Introduction

We have a situation where users are only allowed to create opportunities by qualifying leads. While we've removed the "New" button using Ribbon Workbench, some users are still accessing the Fast Create option from the top navigation in Dynamics 365.

Solution

There isn't a direct solution to remove items from the Quick Create top navigation bar in CRM 365. As a workaround, I implemented a JavaScript function that triggers an alert when the Quick Create form loads, prompting the user and then closing the form.

//Call the pop-up ("Operation not allowed...") that comes before calling Xrm.Page.ui.close()
function displayAlertDialogTextOperationNotAllowed() 
{
	var lookupField = Xrm.Page.getAttribute("originatingleadid");
	if (lookupField != null && lookupField.getValue() == null) 
	{
		//Hide and disable all controls on the form
		Xrm.Page.ui.controls.forEach(function (control, i) 
        {
            control.setDisabled(true);
            control.setVisible(false);
        });	
		
		var alertStrings = {
		confirmButtonLabel: "OK",
		title: "Operation not allowed",
		text: "Please create the Opportunity from lead."
		};
		
		var alertOptions = { height: 200, width: 300 };
		
		Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
			function (success) 
			{
				Xrm.Page.ui.close();
			},
		function (error) 
			{
				console.log(error.message);
			}
		);
	}
}

The result after the user clicks on Quick Create Opportunity will appear as shown in the snapshot below.