Hide Ui action button on incident form on state change

PriyanshuVerma1
Tera Expert

We have a UI action button on incident form header called "Resolve Incident". We want to hide that button when State is changed to cancelled. For that I created a on change client script on incident table which is 

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading || newValue === '') {
    return;
  }
  
  // Check if the new value is "Cancel"
  if (newValue === '9') { 
    // Hide the UI action button
    g_form.setDisplay('d7e9b3701b6433004e9e97d58d4bcbcf', false);
  }
}

Now when I go to any active incident and change state to cancel, there is no change on form. Resolve button is still there. Can you guide me on how to achieve this

23 REPLIES 23

Can you help me with condition in ui action. 

Ankur Bawiskar
Tera Patron
Tera Patron

@PriyanshuVerma1 

UI actions are shown/hidden based on UI action condition.

you can show/hide UI action using DOM manipulation but it's not best practice and not recommended.

If you still want then check this link

How to hide UI Action based on field change in form without using DOM? 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@PriyanshuVerma1 

Any update to this?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

I went to my client any they didn't want to go with DOM manipulation as servicenow doesn't support that

@PriyanshuVerma1 

thanks for confirming what I mentioned above.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader