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 CRM (Archived)

show/hide tab...

(0) ShareShare
ReportReport
Posted on by 26

I am having an issue trying to hide and show a tab based on another fields value.

I have a field called, "Record Type" and this field is an option set.  When this field is equals "Medicare" I want the tab to appear and when it doesn't I want it to hide.  I currently have the checkbox "default visiable" on this tab unchecked.

function RecordTypeOnChange()
 {
 var RecordType = Xrm.Page.getAttribute("nhs_recordtype").getSelectedOption();
 
  if (RecordType == "Medicare")
  {
  Xrm.Page.ui.tabs.get("tab_grievances").setVisible(true);
  }
 else if (RecordType != "Medicare")
  {
  Xrm.Page.ui.tabs.get("tab_grievances").setVisible(false);
  }
 }

Any help is greatly appreciated, thank you.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    Hi,

     try using getText:

    var RecordType = Xrm.Page.getAttribute("nhs_recordtype").getSelectedOption().getText();

  • USA80 Profile Picture
    26 on at

    I know get an error that says, "Object doesn't support property or method 'getText'

  • Verified answer
    ashlega Profile Picture
    34,477 on at

    ah.. sorry.. remove getSelectedOption:

    var RecordType = Xrm.Page.getAttribute("nhs_recordtype").getText();

  • USA80 Profile Picture
    26 on at

    Thank you.  By chance, why would it work with getText and not with getOption?

  • ashlega Profile Picture
    34,477 on at

    It probably would, but you'd have to use

    getSelectedOption().text

    getSelectedOption returns an "Option" object with text/value properties.. and, besides, you may have to check if it's null first.. otherwise, you'll get an error asking for "text" when nothing has been selected

  • USA80 Profile Picture
    26 on at

    what would the string be to hide/show a field based on 2 other fields?  so instead of .tab what would it be?

  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    If you wanted to hide a control, you could use

    Xrm.Page.getControl(arg).setVisible(bool)

    msdn.microsoft.com/.../gg334266.aspx

  • USA80 Profile Picture
    26 on at

    Thank you

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans