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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Tab Hiding

(0) ShareShare
ReportReport
Posted on by

Hi

In my requirement we need to hide mutiple tabs when form loads,like when we click new to create record and when we again open the created record to update
these needs to be hided and after saving the record too. Depending upon the checkboxes only related tabs need to be show other tabs should always be hided.
How to achieve this. I am using below javascript

function enableOrDisableFields() {
    var isCreateForm = (Xrm.Page.ui.getFormType() == 1);
    var isUpdateForm = (Xrm.Page.ui.getFormType() == 2);
    if (isCreateForm === true) {
    
        Xrm.Page.ui.tabs.get("tab_TabGroupSelector").setVisible(false);
        Xrm.Page.ui.tabs.get("tg0_Tab2").setVisible(false);
        Xrm.Page.ui.tabs.get("tg0_Tab3").setVisible(false);

    } else if (isUpdateForm === true) {
      
              Xrm.Page.ui.tabs.get("tab_TabGroupSelector").setVisible(false);
              Xrm.Page.ui.tabs.get("tg0_Tab2").setVisible(false);
              Xrm.Page.ui.tabs.get("tg0_Tab3").setVisible(false);
          // code to be executed if the current form is an Update Form
    }

By using this script only tab_TabGroupSelector is hiding not the other tabs. One more issue is tab_TabGroupSelector shoulb be visible
when we check the field called ABC. tab_TabGroupSelector is visible when we check the field ABC while creating the form but once we save and reopen the record its hided even the field is checked.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rahul G J Profile Picture
    605 on at

    Hi Ayesha,

    Have to performed this ?

    >> Go to the form editor and double click on "tg0_Tab2" tab and set the property "visible by default" to false (Uncheck it). If this is checked, your tab will be visible irrespective of your java script setting it to false. Do the same for all the 3 tabs and check how it behaves.

    Hope this helps.

  • Community Member Profile Picture
    on at

    Thanks for the reply, But its already unchecked.

  • Suggested answer
    Rahul G J Profile Picture
    605 on at

    If you have checked your code, you have set all tabs to false! and no were you have set it to visible "true"! please check it.

  • Suggested answer
    Community Member Profile Picture
    on at

    Rahul is right. You are only setting tab's visibility to false. That means it will remain hidden. You need to set the visibility to true when you want to show the tab.

  • Community Member Profile Picture
    on at

    Hi Rahul,

    Thank you so much for the reply. Actually in my case i have check box category, if they check that box it should show the ralated tabs and if they uncheck that one it needs to hide. Now its working fine by using below script. but i have other isssue can you please help me to fix it.

    function ShowHideTab() {

       if (Xrm.Page.getAttribute("new_ABC").getValue() === true) {

           Xrm.Page.ui.tabs.get("tab_TabG").setVisible(true);

           Xrm.Page.ui.tabs.get("tab_A").setVisible(true);

           Xrm.Page.ui.tabs.get("tab_B").setVisible(true);

           Xrm.Page.ui.tabs.get("tab_C").setVisible(true);

           Xrm.Page.ui.tabs.get("tab_D").setVisible(true);

           Xrm.Page.ui.tabs.get("tab_E").setVisible(true);

        } else {

           Xrm.Page.ui.tabs.get("tab_TabG").setVisible(false);

           Xrm.Page.ui.tabs.get("tab_A").setVisible(false);

           Xrm.Page.ui.tabs.get("tab_B").setVisible(false);

           Xrm.Page.ui.tabs.get("tab_C").setVisible(false);

           Xrm.Page.ui.tabs.get("tab_D").setVisible(false);

           Xrm.Page.ui.tabs.get("tab_E").setVisible(false);

              }

    }

    The issue is:

    I have a CheckBox fields like A,B,C. when user selects A it will show the tab_A, tab_B, tab_C. In these tabs user will fill the only one tab form whatever related and saves. So till here its working fine but once i save the record and reopen the saved record the filled tab is hided again its not showing. Example:If the A field is choosen then it shows tab_A,tab_B and tab_C.  So i only need to fill tab_B depending upon the scenario and save the record. so when i reopen the record tab_B should be visible rest should be hided. I think i need to write script for onsave. But i have no idea. Please guide me throuh this.

  • Verified answer
    Rahul G J Profile Picture
    605 on at

    Hi Ayesha,

    I assume that checkbox java-scripts are working fine for you. Now you have a problem wherein you need to hide/show the tab when the form loads.

    So assuming this, write a similar script in the form's onload section, depending upon what tab/field to be shown when the form loads.

    To do this navigate to customization >> Entity >> form >> in the action pane find "Form Properties" and add your custom java script to hide/un-hide you tabs/fields

  • Community Member Profile Picture
    on at

    Hi,

    Use the same JS which you used for checkbox on change on the form onload event.

    Regards

  • Community Member Profile Picture
    on at

    Thank you so much

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans