Tuesday 12 May 2015

OpenQuickCreate - MS CRM 2015 Update 1

Here is one more new feature which was introduced in CRM 2015 Update 1. i.e openQuickCreate

Now, we can open quick create forms using JavaScript and also the wonderful thing here is You can use this function to set default values using attribute mappings or for specific attributes. If the user saves the record, you can capture a reference to the record created.

For testing purpose, I have created a pick list and written the below code on the change of pick list.

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

Here is the JavaScript code

function CreateQuickCreateContact() {
    var account = { entityType: "account", id: Xrm.Page.data.entity.getId() };
    var callback = function (lookup) {
        console.log("Created new account with name" + lookup.savedEntityReference.name + " and id:" + lookup.savedEntityReference.id);
    }
    var errorCallback = function (lookup) {
        console.log("Error");
    }
    var setName = { name: "Child account of " + Xrm.Page.getAttribute("name").getValue() };
    Xrm.Utility.openQuickCreate("account", account, setName).then(callback, errorCallback);
}


I have added this code to trigger on the change of pick list.

On change of the field


If you observe, it opened the quick create form with the name parameter which is passed from java script.


 After the save, a callback function is called.


  
 --
Happy CRM'img
Gopinath 

No comments:

Post a Comment