How to Open Quick Create form in Dynamics CRM 2015 Online Update 1

By | July 2, 2015

You might be aware of how to open CRM entity form using javascript function that was introduced in Dynamics CRM 2013 i.e. Xrm.Utility.openEntityForm()

If you are not then you can refer our blog about this feature here. We use openEntityForm function to open blank entity form or entity form with pre populated values.

In CRM 2013 there was new feature introduced called Quick Create Form, using quick create form user can quickly create new record by staying on the same page.

The quick create form opens as below,

form

And there was no function or an option to open such quick creates form programmatically.

Sometimes we may need to open Quick create form programmatically. Microsoft has introduced new function in Dynamics CRM 2015 Online Update 1 to open quick create form same as open entity form.

This blog will illustrate how to open Quick create form.

Now there is one function available under Xrm.Utitlity called ‘openQuickCreate’ that open entity open form as shown in above screen shot.

Syntax,

Xrm.Utility.openQuickCreate(entityLogicalName,createFromEntity,parameters).then(successCallback, errorCallback);

Here,

entityLogicalName: Accept string value. Pass logical name of entity for which we need to open quick create form,

createFromEntity: Accept a lookup object, Pass lookup object that will provide default values based on mapped attributes values.

parameters: Accept a object, pass extra querystring parameters. We can pass field values as a parameter to set field values on the quick create form.

successCallback: This is a function that will call when record is created. It returns a lookup object of created record.

errorCallback: This is a function that will be called when error occurred. It returns errorCode and message.

From all above parameter only entityLogicalName is required and others are optional.

Below is an example where we will open Quick Create form to create a new child account from account entity form with some pre populated values.

//lookup object of current account record

var parrentAccount = {

 entityType: “account”,

 id: Xrm.Page.data.entity.getId()

};

var parameters = { name: “Child account of ” + Xrm.Page.getAttribute(“name”).getValue(), address1_postalcode: Xrm.Page.getAttribute(“address1_postalcode”).getValue() };

Xrm.Utility.openQuickCreate(“account”, parrentAccount,parameters ).then(function (lookup) { successCallback(lookup); }, function (error) { errorCallback(error); });

function successCallback(lookup)

{

        window.console.log(“lookup: ” + lookup.savedEntityReference.id);

}

function errorCallback(e){

        window.console.log(“Error: ” + e.errorCode +” “+e.message);

}

Above code opens a quick create form with auto populating name and postal code from parent account.

form1

The successCallback() calls when you save the record.

Hope it helps!

Before you move to the next post, have you seen our new Click2Export Solution. A 1 click solution to export reports to Word/Excel and Pdf. Email us on crm@inogic.com for a trial or if you would like to see a live demo.

Leave a Reply