Close Quick Create Form in Microsoft Dynamics CRM 2013.

Recently in my project, I came across a requirement where the customer would launch the quick create form and when he clicks on the Save button, our CRM system would perform complex business functions and show a pop-up to the user with a list of available options. If the user selects one of the options from the pop-up, our requirement was to close out the Quick Create form without saving the record.

Our initial guess was to try out the Xrm.Page.ui.close() to close the global quick create form. However that didn’t work.

After quite a bit of exploring the CRM system libraries, finally I could find out a way. CRM uses the .js file GlobalQuickCreateBehavior.js to perform all functions related to Quick Create. The file is located in

<CRM Installation folder>/CRMWeb/_static/_controls/GlobalQuickCreate folder.

 

A little bit of formatting the .js file and voila you have all the wonderful functions that CRM uses for its Quick create Functionality. Just a quick glance below.

Know more on how to open CRM system javascript files in readable format? Checkout my post at this URL – https://debajmecrm.com/exploring-microsoft-dynamics-crm-system-js-file/

image

 

Since this article is all about closing the Quick Create Form, let us quickly explore the function that we need. The following is the screenshot of the function that you can use to close your Quick Create Form.

image

All you need is to call the highlighted function Mscrm.GlobalQuickCreate.GlobalQuickCreateBehavior.closeAllGlobalQuickCreateForms() to close the Quick Create Dialog and you are done.

Please note: this is a system function and any changes done by Microsoft Team in the library would render your code un-usable.

 

Hope this helps!

4 thoughts on “Close Quick Create Form in Microsoft Dynamics CRM 2013.”

  1. Hi, I found that functionality as well, but I have problems with programatically launching any QuickCreateForm.
    Can you please provide any info about creating Mscrm.GlobalQuickCreate.GlobalQuickCreateBehavior object to show any QcreateForm.

    1. Hi Iszeka,
      Thanks for reading my blog.
      I also tried to launch quick create from anywhere. I even tried to pass in all the parameters that are required for the Launch method. However what i finally understood is that, the launch of the Quick Create is contextual and some of the parameters is derived at runtime from the context it was launched. I was not able to mock that.
      However if you are able to find any alternative way, please let me know.

      1. Problem I’ve stumled is proper initialization of callbacks object.
        Beside that I can sucessfully call Mscrm.GlobalQuickCreate.GlobalQuickCreateBehavior.launchGlobalQuickCreate.
        Executing any JS code can be done via. RibbonButton command. But building navigationMenu is done in outer scope so I declared own method in ribbon button command action js:
        Mscrm.NavStatusInParent = function (notificationAreaElementId, animationStrategy) {
        if (isNullOrEmptyString(notificationAreaElementId))
        throw Error.argumentNull(“notificationAreaElementId”);
        if (IsNull(animationStrategy))
        throw Error.argumentNull(“animationStrategy”);
        debugger;
        this.$T_0 = $P_CRM(window.parent.document).find(notificationAreaElementId);
        if (IsNull(this.$T_0) || this.$T_0.length !== 1)
        throw Error.argument(“notificationAreaElementId”);
        this.$1G_0 = animationStrategy;
        };
        After that in ribbon button click:
        var timestamp = ‘{“formts”:”5369114″,”mdts”:”-2036263796″,”userts”:”130664804969930961″,”businessRulesVersion”:”1033″}’;
        var qcTimeStamp = ‘”QuickCreateTimestamp”:’ + JSON.stringify(timestamp);
        var node = ‘{“Action”:{“ActionType”:”GlobalQuickCreateAction”,”EntityName”:null,”EntityTypeCode”:123,”PageUrl”:null, ‘ + qcTimeStamp + ‘},”Caption”:”Competitor”,”Children”:[],”ColorAccent”:”#555555″,”DefaultNode”:false,”Enabled”:false,”Id”:”{983909d6-6ae1-45a7-bd60-1a496d5bee7f}”,”ImageUrl”:”/_imgs/NavBar/ActionImgs/Competitors_32.png?ver=-169041740″,”NodeType”:1,”ParentId”:null}’;
        var nodeObject = JSON.parse(node);
        // Entire page load – part of: Mscrm.NavBar = function ($p0)
        var navStatus = new Mscrm.NavStatusInParent(“#navStatusArea”, new Mscrm.NavStatusBarAnimationStrategy());
        var actionProviders = {};
        actionProviders[“GlobalQuickCreateAction”] = new Mscrm.GlobalQuickCreateActionProvider(navStatus, { Name: “MScrm.NavBar”, Role: “ParentControl” });
        var factory = new Mscrm.NavigationNodeActionFactory(actionProviders);
        // Onclick competitor tile in quickCreate
        var qcAction = factory.createAction(nodeObject);
        qcAction.execute();
        Everythings gets fine until: Mscrm.NavBarGlobalQuickCreateCallbacks.initializeBase(this, [quickCreateFrameId, 990]); whis can not properly return calbacks.

Comments are closed.