Hiding UI action based on conditions

Ashwi
Tera Contributor

I have requirement to make hide UI action from form  if logged In user and assigned to users are same. UI action is not sc_task table. Is it good practice if we make changes in OOTB UI action? What are all possible ways?

Thanks, Bilbo

1 ACCEPTED SOLUTION

AbhishekGardade
Giga Sage

Hello Bilbo,

1. To achieve your requirement, you need to add a simple condition: current.assigned_to!=gs.getUserID()  condition Builder.

2. You need to override that UI action as its not best practice to modify any OOTB UI action.

3. Create New UI action and override with OOTB UI action that you want to hide

Alternative way for hiding UI action is with the help of DOM manipulation. Its not recommended by ServiceNow.

1. You need to write onLoad Client script and Make sure that you uncheck the field ISOLATED SCRIPT:

2. Add following code:

/Remove the 'Submit' button 
var items = $$('BUTTON').each(function(item){
   if(item.innerHTML.indexOf('Submit') > -1){
      item.hide();  
   }
});

3. Check out this useful blog:

https://www.servicenowguru.com/scripting/client-scripts-scripting/removing-form-buttons/

Please mark as Correct Answer/Helpful, if applicable.
Thanks!

Abhishek

 

Thank you,
Abhishek Gardade

View solution in original post

5 REPLIES 5

Prabhjot3
Kilo Expert

Just put the Action name in hide function

hide('btn_assess');