Pages

Sunday, 7 July 2013

Show or Hide a tab in the form onload using javascript

This function is used for hiding a tab in onload event.
Using Javascript, we can easily show or hide a tab on a form.
The following functionality works as hide a tab in new form and show that tab again in existing form.

function tabHide()
{
  var formType=Xrm.Page.ui.getFormType();
  if(formType==1)
  {
     Xrm.Page.ui.tabs.get("tab_details", "collapsed", false).setVisible(false);
  }
  else
  {
     Xrm.Page.ui.tabs.get("tab_details", "collapsed", false).setVisible(true);
  }
}

                                          (OR)


function tabHide()
{
  var formType=Xrm.Page.ui.getFormType();
  if(formType==1)
  {

//Here 1 is mentioned that this is a second tab("Details" tab in my contact page) in a form
     Xrm.Page.ui.tabs.get(1).setVisible(false);  
  }
  else
  {
     Xrm.Page.ui.tabs.get(1).setVisible(true);
  }
}

No comments:

Post a Comment