Enable +New button in the Lookup view of the Dynamics 365 portal.

Hello Everyone,

I have been seen a lot of people were finding a way or solution to add a custom button or \’New\’ button inside Lookup dialog in order to create a new record directly from Portal if not found in lookup Search result.

Here are the few links where it has been asked:



Here is the code I have written to achieve the same:

// Calling of Function

AddNewButton_InLookupDiaog(\’customerid\’,\’Select\’,\’customeridNewBtnId\’,\’Add New\’,\’~/create-account\’,\’Authenticated\’);

// lookupfieldScehmaName = schema name of lookup field
// NewButtonPosition = Position, where you want to place the \’New\’ Button inside Lookup Window
// NewButtonId = Id of New Button, Make sure this should be unique
// NewButtonText = text to display of New Button
// NewButtonActionURL = Provide webpage partial URL or the page where you want to redirect the user in order to create new record
// Webrole = Role to which \’New\’ button should be visible. If passed \’Authenticated\’ then \’New\’ would be visible to Authenticated Users only.

// Function Definition

function AddNewButton_InLookupDiaog(lookupfieldScehmaName,NewButtonPosition, NewButtonId,NewButtonText,NewButtonActionURL,Webrole)
var loggedInUserRole = \'{{user.roles}}\’;

if(loggedInUserRole.indexOf(Webrole) == -1){
var elementId = lookupfieldScehmaName+\”_lookupmodal\”;

$(\”#\”+elementId).closest(\’table\’).on(\”loaded\”, function ()
var IsAddNewButtonAdded = $(\”#\”+NewButtonId).length;

// If button is not added then add the button
if(IsAddNewButtonAdded == 0)
$(\”#\”+elementId).find(\’button:contains(\”\’+NewButtonPosition+\’\”)\’).before(\'<button id="'+NewButtonId+\’\” aria-label=\”New\” class=\”primary btn btn-primary\” tabindex=\”0\” title=\”New\” type=\”button\” onclick=\”NewButtonAction(\’+\”\’\”+NewButtonActionURL+\”\’\”+\’)\”>\’+NewButtonText+\’\’);

function NewButtonAction(redirectionURL)


Log in to CRM Portal :

We are going to add a \’Add New\’ button in \’Customer\’ Lookup Dialog:

Press F12 or Inspect to get the Schema name of the lookup field. You can check the schema name of the field from CRM also from Form Customization :

Add code to Add Add \’New\’ button in Customer Lookup Dialog :

Open Web page > Go to Advanced Tab > Custom Javascript and paste the given code as mentioned below:

Output :

Once clicked on \’Add New\’

Let\’s have a look all the Parameters one by one:

Parameter 1 – lookupfieldScehmaName:

For Example, It\’s value =  \’customerid\’

Parameter 2 – NewButtonPosition:

For Example, It\’s value =  \’Select\’

Parameter 3 – NewButtonId:

For Example, It\’s value =  \’customeridNewBtnId\’

Parameter 4 – NewButtonText:

For Example, It\’s value  = \’Add New\’

Parameter 5 – NewButtonActionURL:

For Example, It\’s value =  \’~/create-account\’

Parameter 6 – Webrole:

For Example, It\’s value = \’Authenticated\’

Note – 

  • To add \’New\’ button in multiple lookups on the form, you just need to call the function again with required parameters of each lookup. The Function definition will remain same.
  • Make sure you are providing the unique Id for each button (\’New\’) for every lookup dialog.

Please do not forget to share your feedback:

Cheers 😎


Published by arpitpowerguide

My name is Arpit Shrivastava, who is a Microsoft MVP in the Business Applications category. I am a Microsoft Dynamics 365 and Power Platform enthusiast person who is having a passion for researching and learning new things and acquiring immense knowledge. I am providing consistent help, support, and sharing my knowledge through various Social Media Channels along with my Personal Blog, Microsoft Community, conducting online training and attending various 365 Saturday Events worldwide and sharing the best Solutions to the readers helping them achieve their goals and objectives in Customer Relationship Space.

8 thoughts on “Enable +New button in the Lookup view of the Dynamics 365 portal.

  1. Hiya, I am really glad I’ve found this information. Nowadays bloggers publish only about gossip and web stuff and this is really irritating. A good blog with interesting content, this is what I need. Thanks for making this web-site, and I will be visiting again. Do you do newsletters by email?start up firm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: