Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Swap the form on custom ribbon button click

Posted on by 1,000

In a Entity i have 3 form like Form 1,Form 2,Form 3. The Form 1 is a default Form.

In ribbon I have "Swap Form " Custom Button. Now i Click on this button i need to change the Form 1 to Form 2.

I use the following code,

Xrm.Utility.openEntityForm(name,id,parameters,windowOptions)

Its opening in the new window i don't want like this open in a new window.I need to swap the Form 1 to Form 2.

Any Idea ? Thanks in advance .

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Swap the form on custom ribbon button click

    Use below code:

    function buttonClick(){
    
       var lblForm = "Form 1";
       
       //check if the current form is form need to be displayed based on the value
       if (Xrm.Page.ui.formSelector.getCurrentItem().getLabel() != lblForm) {
           var items = Xrm.Page.ui.formSelector.items.get();
           for (var i in items) {
               var item = items[i];
               var itemId = item.getId();
               var itemLabel = item.getLabel()
               if (itemLabel == lblForm) {
                   //navigate to the form
                   item.navigate();
               } //endif
           } //end for
       } //endif
    }


  • vijay12872 Profile Picture
    vijay12872 1,000 on at
    RE: Swap the form on custom ribbon button click

    I need to open the specific form while click the button. In my entity "Form1" is default. but Form2 ,form 3 are available.If I use the above code its opening "Form1" because its a default form.But I need to open "Form 2" on button click .

  • vijay12872 Profile Picture
    vijay12872 1,000 on at
    RE: Swap the form on custom ribbon button click

    @mohd saad akhtar I need to open the specific form while click the button. In my entity "Form1" is default. but Form2 ,form 3 are available.If I use the above code its opening "Form1" because its a default form.But I need to open "Form 2" on button click.

  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Swap the form on custom ribbon button click

    Hi Vijay,

    windowsOptions is the option which controls whether form needs to be opened in the new window or in the same window. The default value for this parameter is false, if wants to open in new window then we need to specify a true value for this parameter. It is an optional parameter which can be omitted. 
    For more details on this function, please refer the blog below.

    https://mahadeomatre.blogspot.in/2016/10/xrmutility-functions-openentityform.html

    Hope this helps you.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Swap the form on custom ribbon button click

    Remove windowoptions from the line:

    Xrm.Utility.openEntityForm(name,id,parameters)

    Refer this:

    http://www.magnetismsolutions.com/blog/gayanperera/2013/07/24/how-to-switch-a-dynamics-crm-form-based-on-a-value

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

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