Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Javascript

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

5.00/5 (1 vote)
13 Oct 2024CPOL 2K  
Remove an Entity from top bar fast Quick Create in Microsoft Dynamics 365
Change the list of records users can create via the top command bar Plus Sign on Dynamics CRM 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.

Image 1

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.

JavaScript
//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.

Image 2

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)