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://debajitcrm.wordpress.com/2014/08/05/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!

Advertisements

About Debajit
I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

4 Responses to Close Quick Create Form in Microsoft Dynamics CRM 2013.

  1. lszejka says:

    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.

    • Debajit says:

      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.

      • lszejka says:

        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.

      • Debajit says:

        Great indeed! I will take a cue from your code and try to bring this to closure.
        Thanks for sharing the code!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: