Hide tab on a specific state of the form

Alessia Russo
Tera Expert

Hi everybody! I would like to hide some custom tab on my task form until it reaches some states, and after make it appear on the form. Is there a way without script for do that? Or it is possible anyway? If it's possible only with script, could somebody tell me which one should I use?

Thanks

1 ACCEPTED SOLUTION

benn23
ServiceNow Employee
ServiceNow Employee

Ahh, I see.  You're actually updating the record which is re-loading the form.  Your client script is not set up to run on load (2nd line of client script).  If you need this to run on form load, comment out lines 2-4.  

View solution in original post

15 REPLIES 15

@benn23 ok, now I see if I change manually the state the tab dissapear, but I want that it hide or appear when It changes state with a UI Action. Should I put the script in the UI Action or I have to add something in the script?

benn23
ServiceNow Employee
ServiceNow Employee

Setting it w/ a UI Action should trigger the client scripts to fire.  Can you share your UI Action script?

@benn23 here the script of the ui action:

(function(){
current.state = 127; // set the opened task state to the new one
current.update(); // update the opened task to save the changed state
action.setRedirectURL(current);
})();

 

as you can see it only changes the state in 127, so I think that if it changes in 127 the script should work and make the tab dissapear, should I add something in the script of the ui action?

benn23
ServiceNow Employee
ServiceNow Employee

Ahh, I see.  You're actually updating the record which is re-loading the form.  Your client script is not set up to run on load (2nd line of client script).  If you need this to run on form load, comment out lines 2-4.  

@benn23 ok now it works! Thank u!