Using Xrm.Navigation.openForm to Open Quick Create in Dynamics 365

2 Comments

We can use Xrm.Navigation.openForm to open a Quick Create using JavaScript.

Let’s say we want to open the Account quick create form on a Contact record in the Unified Client Interface / Unified Interface. Let’s go to a contact record:

To simply open the quick create without setting any field values, we can use the code:

var entityFormOptions = {};
entityFormOptions["entityName"] = "account";            
entityFormOptions["useQuickCreateForm"] = true;
Xrm.Navigation.openForm(entityFormOptions, null).then(
                function (lookup) { console.log("Success"); },
                function (error) { console.log("Error"); }
                                             );

Hitting F12 to run this code in developer tools, we see the quick create is open:

To set the values of fields, we can pass a 2nd parameter with the fields:

 

var entityOptions = {};
entityOptions["entityName"] = "account";            
entityOptions["useQuickCreateForm"] = true;

var formParameters = {};
formParameters["name"] = "Test account";

Xrm.Navigation.openForm(entityOptions, formParameters).then(
                function (lookup) { console.log("Success"); },
                function (error) { console.log("Error"); }
                                             );

This defaults the name to Test Account on the account quick create:

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

2 Responses to Using Xrm.Navigation.openForm to Open Quick Create in Dynamics 365

    • Hi Nik,

      Yes, you can call the same code from an HTML web resource, you can put it into a JS function and call the function onclick or ondblclick.

Leave a Reply

Your email address will not be published. Required fields are marked *