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,...
Answered

Hide/show tab based on form type (create/update)

(0) ShareShare
ReportReport
Posted on by

I am trying to use JavaScript, which is definately not my expertisie, to hide/show a tab on a form based on the form type of record. 

If form type is 1 (create) I want to hide the summary tab. If the form type is 2 (update), I want to show the summary tab. 

I have Googled me to the code below, which I use on load of the form - and that works to some extent. 

//Hide Summary tab on Create form 
function HideSummaryTab(executionContext) {   
  //Get form context   
  var formContext = executionContext.getFormContext();   
  //Get form type   
  var formType = formContext.ui.getFormType();   
  //If formtype is Create, hide Summary tab on form     
  if (formType == 1) {
    formContext.ui.tabs.get("summary").setVisible(false);   
  }   
  //To see the form type return value in your browser console
  console.log("Form type = "   formType); 
}

However:

1. Is there any way to avoid the delay there is when the form is loaded? First it loads the form - then it hides the tab. Not the best user experience. 

2. What is the best way to show the tab after save? Do I need to modify the code above, and add an on save event? 

I have the same question (0)
  • Verified answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    HI,

    Code looks good. 

    I have below suggestion for above need:

    1. By default keep the tab visibility to hide using below property. So, on create(formType==1) the tab will be hidden. 
    pastedimage1635784335575v1.png

    2. When user update the record (formType==2) then use below JavaScript to show the tab.

    //Hide Summary tab on Create form 
    function HideSummaryTab(executionContext) {   
      //Get form context   
      var formContext = executionContext.getFormContext();   
      //Get form type   
      var formType = formContext.ui.getFormType();   
      //If formtype is Create, hide Summary tab on form     
      if (formType == 2) {
        formContext.ui.tabs.get("summary").setVisible(true);   
      }   
    
    }



    With above approach user will consistent experience. 

    Thanks,
    Pradeep.

    Please mark this as VERIFIED. if it helps.

  • NielsSL Profile Picture
    on at

    Thanks for your reply, Pradeep Rai 

    In your code, i just need to change setVisbility to true :)

    I played a bit around with this, and I came to the conclusion, that using setFocus works better for my use case. 

  • Pradeep Rai Profile Picture
    5,489 Moderator on at

    HI,

    Yes, we need to change the setVisibilty true. later i updated the same code.

    Thanks.

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 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans