web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / MS CRM Customization / Xrm.Utility functions : ope...

Xrm.Utility functions : openQuickCreate

Mahadeo Matre Profile Picture Mahadeo Matre 17,021

There is another good function in Xrm.Utility object : openQuickCreate. This function is only available for CRM 2015 (update 1) online or later versions.
Using this function we can open quick create form for entity even there is not any direct relationship.
e.g. if you have any custom entity, and this custom entity is not has any relationship with contact but for some reason when this custom entity form opens, you want to create contact / want to open contact quick create, you can use this Xrm.Utilityfunction.
With openQuickCreatefunction, you can set default values on form by passing parameters and/or by using query string parameters and/or using attribute mapping defined in relationship.
Common syntax for openQuickCreateis

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

To open any entity quick create form only entityLogicalName is required, other parameters are optional.

When wants to open just quick create form without setting any default values, then we can use

Xrm.Utility.openQuickCreate( "contact",);

This will open quick create form for contact entity.

For all details about parameters, please check


The complete example of openQuickCreateForm is

carScript = {

    onLoadEvent:function()
    {       
        var thisEntityRecord = {
            entityType: "new_car",
            id: Xrm.Page.data.entity.getId(),
            name: Xrm.Page.getAttribute('new_name').getValue()
        };
        var parameters = {};
        parameters["new_manufactureaddress"] = Xrm.Page.getAttribute('new_manufactureaddress').getValue(); 
  
        Xrm.Utility.openQuickCreate("new_manufacture", thisEntityRecord, parameters).then(carScript.setManfactureLookup,carScript.errorfun);

    },
    setManfactureLookup:function(manfObj)
    {
        var lookup = new Array();
        lookup.push(manfObj.savedEntityReference);
        Xrm.Page.getAttribute('new_manufactureid').setValue(lookup);
    },
    errorfun:function(error)
    {
        Xrm.Utility.alertDialog(error);
    },
};

This function is called on form load; once form is loaded, quick create form for Manufacture (custom entity) will be displayed.  Once quick create record is saved, setManfactureLookup is called, which will set Manufacture lookup in car entity.
 When quick create record saved, you will get saved record entity reference object in SuccessCallbackfunction.

Note: There is a limit of 10 nested quick create forms in the web application. If this limit is exceeded this function will open the full entity form rather than quick create form. 

This was originally posted here.

Comments

*This post is locked for comments