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

@PriyanshuVerma1 

Did you try script I shared?

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

I tried the solution of changing the spelling, but it is still the same. It's not working on cancel state

Please check in the IncidentState script include if the value of your cancelled state matches the cancelled state value in the script.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

I tried everything, i made the values of incident_State and state for cancelled field same to be in sync. But it's not working so I raised a case with servicenow support. Thnaks for helping me on this

I just checked the oob script include "IncidentStateSNC" in dev and sandbox. In this value of both closed and cancelled state is set as "7". But in oob instances i checked value of canceled state is set at '8' in script include, But the script is set at read only so I can't edit it. I guess that is causing the issue? Any suggestion on how to fix it