Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Hide Tab using a condition on a calculated text field

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);
}
}

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Hide Tab using a condition on a calculated text field

    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

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans