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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Hide and show tabs based on text value

(0) ShareShare
ReportReport
Posted on by 27
Hi everyone,
 
On an OnLoad event for a Form, I have the following expression which works for hiding a tab and showing a different tab based on the value of a text field.
 
function HideTabOne() {   if(Xrm.Page.getAttribute(/column_logical_name/).getValue() == /Test 1/) {       Xrm.Page.ui.tabs.get(/tab_one/).setVisible(false);   }   else {       Xrm.Page.ui.tabs.get(/tab_two/).setVisible(true);   }}
 
How could I add an additional condition to this expression so that if the text field equals /Test 2/, then tab_one should be visible, and tab_two should be hidden?
 
Best regards,
 
I have the same question (0)
  • Suggested answer
    RudyZhang Profile Picture
    Microsoft Employee on at
    Hi,
     
    Regarding the issue that you want to hide or show the tabs according to certain conditions
     
    Our team has modified the code you provided to meet your needs, the modified code is as follows.
    function HideTab() {
        var textFieldValue = Xrm.Page.getAttribute('column_logical_name').getValue();
        
        if (textFieldValue === 'Test 1') {
            Xrm.Page.ui.tabs.get('tab_one').setVisible(false);
            Xrm.Page.ui.tabs.get('tab_two').setVisible(true);
        } else if (textFieldValue === 'Test 2') {
            Xrm.Page.ui.tabs.get('tab_one').setVisible(true);
            Xrm.Page.ui.tabs.get('tab_two').setVisible(false);
        }
     }
    In this code above, we store the value of the text field in a variable called textFieldValue to improve readability. Then, we added an additional if condition to check if the value is equal to "Test 2". If it is, tab_one is set to visible and tab_two is set to hidden. You can adjust the "Test 1" and "Test 2" values to meet your business needs.
     
    I hope my answer is helpful to you! If you have any other questions, please feel free to contact me.
     
    Best Regards,
    Rudy Zhang
  • Ami K Profile Picture
    27 on at
    Thank youRudyZhang!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 149

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 79 Super User 2026 Season 1

#3
ManoVerse Profile Picture

ManoVerse 62 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans