Skip to main content

Notifications

Dynamics 365 general forum

Open a quick create form in UCI forms

Posted on by Microsoft Employee

Hello All,

I am trying to open the quick create form, from the UCI forms, but it is always opening the default main form. Its working well from the classic web forms. Below is the code i m trying to use. Please let me know in case if i am missing any thing or there is some other way of doing it.

The environment is - Version 1710 (9.1.0.4437) online. 

var entityFormOptions = {};
entityFormOptions["entityName"] = "msdyn_payment";
entityFormOptions["useQuickCreateForm"] = true;
entityFormOptions["formId"] = "62F07FB4-A0AC-4312-A22A-0768E4C6BB86";

        var formParameters = {};
         formParameters["hsl_case"] = formContext.data.entity.getId();
formParameters["hsl_casename"] = formContext.data.entity.getPrimaryAttributeValue();

      
//Xrm.Utility.openQuickCreate("msdyn_payment", parentCase , formParameters).then(
Xrm.Navigation.openForm(entityFormOptions , formParameters).then(
         function (success) {
Xrm.Utility.alertDialog(success.message);
              console.log(success);
         },

        function (error) {
                console.log(error);
         });

  • Suggested answer
    LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Open a quick create form in UCI forms

    Hi partner,

    If you want to pass "primary control"  in ribbon, you should add it as a parameter in ribbonworkbench command.

    community439.png

    I tried almost the same code in my sales hub (I don't have "hsl_case" lookup field in my account form so I annotated them) and it worked well after add the CRM parameter to ribbon command.

    community439.png

    Hope it helps.

    Best Regards,

    Leo

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Open a quick create form in UCI forms

    Hello Leo,

    thank you very much for your suggestion, i tried the above way,

    function addPayment(primaryControl)

    {

           debugger;

    var formContext = null;

    if(isValid(primaryControl))

        formContext = primaryControl.getFormContext();

      else formContext = primaryControl;

            // Set default values for the Contact form

          var parentCase = {

               entityType: "incident",

               id: formContext.data.entity.getId().replace("{","").replace("}","")

          };

    var entityFormOptions = {};

           entityFormOptions["entityName"] = "msdyn_payment";

    entityFormOptions["useQuickCreateForm"] = true;

           entityFormOptions["formId"] = "62F07FB4-A0AC-4312-A22A-0768E4C6BB86";

            var formParameters = {};

             formParameters["hsl_case"] = formContext.data.entity.getId();

            formParameters["hsl_casename"] = formContext.data.entity.getPrimaryAttributeValue();

        //Xrm.Utility.openQuickCreate("msdyn_payment", parentCase , formParameters).then(

            Xrm.Navigation.openForm(entityFormOptions , formParameters).then(

             function (success) {

                 Xrm.Utility.alertDialog(success.message);

                  console.log(success);

             },

            function (error) {

                    console.log(error);

             });

    }

    function isValid(primaryControl)

    {

     debugger;

     var isValidPrimaryControl = false;

      try {

        var myControl = primaryControl.getFormContext();

    isValidPrimaryControl = true;

      }

      catch (e)

      {

         isValidPrimaryControl = false;

      }

      return isValidPrimaryControl;

    }

    but still in the same loop.

    Actually this code is being called from the click of a button.

    Hope you catch the issue in the above code.

  • Suggested answer
    LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: Open a quick create form in UCI forms

    Hi partner,

    I've updated your code here.

    function openCF(executionContext) {
        var formContext=executionContext.getFormContext();
        var entityFormOptions = {};
        entityFormOptions["entityName"] = "msdyn_payment";
        entityFormOptions["useQuickCreateForm"] = true;
        entityFormOptions["formId"] = "62F07FB4-A0AC-4312-A22A-0768E4C6BB86";
        var formParameters = {};
        formParameters["hsl_case"] = formContext.data.entity.getId();
        formParameters["hsl_casename"] = formContext.data.entity.getPrimaryAttributeValue();
    
        //Xrm.Utility.openQuickCreate("msdyn_payment", parentCase , formParameters).then(
        Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
            function (success) {
                Xrm.Utility.alertDialog(success.message);
                console.log(success);
            },
    
            function (error) {
                console.log(error);
            });
    }

    In UCI, we should declear "formContext" by using "executioncontext.getFormContext".

    For example, I want to open quickCreate form of Account in UCI, the code I've changed could work well.

    8030.community435.png

    Remember to select "Pass execution context as first parameter" when adding function to Onload event.

    8030.community435.png

    Hope it helps.

    Best Regards,

    Leo

    
    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans