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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Hide Tab using a condition on a calculated text field

(0) ShareShare
ReportReport
Posted on by 10

Hello,

I am a newbee with Javascript coding.

I want to hide different form tabs based on a calculated text field. My code doesn't seem to work. Can someone help me?

Here's my code:

function changeTab(executionContext)
{
var formContext = executionContext.getFormContext(); 
var accountclass = formContext.getAttribute("gs_accountclass").getValue();
var tabObj = formContext.ui.tabs.get("agreement");
var tabObj2 = formContext.ui.tabs.get("quotes");
tabObj.setVisible(false);
tabObj2.setVisible(false);


if (accountclass == "Class1")
{
tabObj.setVisible(true);
tabObj2.setVisible(true);
}
else if (accountclass == "Class2"){
tabObj.setVisible(false);
tabObj2.setVisible(true);
}
else if (accountclass == "Class3"){
tabObj.setVisible(false);
tabObj2.setVisible(true);
}
}

I have the same question (0)
  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    Hi,

    Have you selected below highlighetd checkbox while registering the event?

    CR28.PNG

    I have used your same code and registered on onchange of Account Class field and form onload , it seems to be working on my instance

    CR29.PNG

    I did notice one thing - In class2 and Class3 you are doing same thing - Hiding Agreement tab and shoing Quotes tab

    is this expected?

    Also, please add your code on form onload.

    I hope you have added your Calculated field on Form.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 107 Super User 2026 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 64 Most Valuable Professional

#3
ParthPatel249 Profile Picture

ParthPatel249 62

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans