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 :
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,983 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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans