Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Trying to hide a tab based on the contents of a field

Posted on by 202
Hi everyone

I'm trying to hide / show a tab based on whether a field contains a value and I'm using the following Javascript which I've added as a Web Resource etc:

function hideShowTab() {
var type = Xrm.Page.getAttribute(/sic_wikipedia/).getValue();
if (Type != //) {
window.parent.Xrm.Page.ui.tabs.get(/tab_16/).setVisible(true);
}
else {
window.parent.Xrm.Page.ui.tabs.get(/tab_16/).setVisible(false);
}
}

So, in this case I don't want tab_16 to be visible if the sic_wikipedia field does not contain data. The tab known as tab_16 (on the Form in PowerApps and in the Javascript) is actually called BURSARIES on the Form as per the image below:

 
However, as you can see, the Wikipedia field is blank but the BURSARIES tab (a.k.a. tab_16) is still showing.

Could anyone please let me know what I'm doing wrong? I have a feeling that it's something to do with the line if (Type != //) { in the Javascript, but changing the word Type to e.g. Wikipedia makes the Javascript crash as it says that Wikipedia is not defined.

Many thanks
Jon

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans