Open Quick Create or Entity Forms From JavaScript

Recently I needed to have some ribbon buttons that would trigger opening both standard and quick create forms. The snippets below show the required syntax.

To open a main form for an entity use ……

var parameters = {
parameters["aField"] = aVariable;
parameters["bfield"] = bVariable;
etc etc etc....

Xrm.Utility.openEntityForm("anyEntityName", null, parameters);

To open a quick create form review the following code example. In this I’ve shown a slightly more comprehensive syntax. (Which could be applied to the openEntityForm above!)

Below I have shown how to call the contact quick create form but in the context of an account. Meaning I pass the Id of the parent account to the quick create form.

I’ve also shown how you could use “.then” to handle both the error and success outcomes. The success function might be useful if you need to do anything with the Id / name of the record just created!

// *** First get the Id of the required account, possibly like this ....
var accountValue = null;
var account = Xrm.Page.getAttribute("parentaccountid");
if (account != null) {
  accountValue = account.getValue();
  if (accountValue != null) {
    var accountId = accountValue[0].id;

// ** Create an object including the accountId. Used to call the 
// ** quick create form in the context of the account
var parentAccount = {
  entityType: "account",
  id: accountId

// *** NOTE: Here we aren't setting any parameters! (But we could!)
var parameters = {};

// *** Call the Xrm.Utility needed to add a contact.
Xrm.Utility.openQuickCreate("contact", parentAccount, parameters).then(function (lookup) { successCallback(lookup); }, function (error) { errorCallback(error);});
// *** Function called on success.
function successCallback(lookup) {
  alert("lookup: " +;
  alert("lookup: " +;

// **** Function called on error.
function errorCallback(e) {
  // *** No new contact created, which is an error we can ignore!
  alert("Error: " + e.errorCode + " " + e.message);

5 thoughts on “Open Quick Create or Entity Forms From JavaScript

  1. Pingback: Happy New Year – Pop Pickers | Microsoft Dynamics CRM and Unified Service Desk

  2. Pingback: New Year’s Eve 2016 | Microsoft Dynamics CRM and Unified Service Desk

  3. Pingback: JavaScript – My Collection - Microsoft Dynamics CRM Community

  4. Hi Neil,

    I was wondering if you could halp me out here. When you say setting paramaters. in which context do you mean in this case? Can you give one or two examples? I would really appreciate it.



    • The parameters can be used to default fields on the form. You may (for example) want to default the telephone number on a contact.

      Maybe something like…
      var parameters = {
      parameters[“telephone1”] = “999”;


Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Connecting to %s