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 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

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 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 58 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 42

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans