Confirmation popup on close incident.

anupriya7
Kilo Expert

As an ESS / ITIL user (legacy view and Portal View) for Incidents and Service Requests, Problem. Once i click on Close UI action Button or user change manually   state to close I should get a pop up message as confirmation "Are you sure you want to close this ticket ?"

Here I am using below code but when click on cancel incident is getting closed for UI action. Any suggestion??

  onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var value =g_form.getValue('incident_state');// field name
if(value==7) // field value
{
if(confirm("Do you want to close"))

{

g_form.save();
}
else
{
g_form.setValue('incident_state',oldValue);

}

  }

}

6 REPLIES 6

ohhgr
Kilo Sage

Hi Anupriya,



Do you have incident_state field on the form layout? g_form.getValue() might not work if the field is not on the form layout. (hidden or otherwise)



This is a onChange client script and you're trying to set the value of the incident state through UI Action on Server Side. If you want to stop the processing of the UI Action, use client script within the UI Action. Something like this Client & Server Code in One UI Action - ServiceNow Guru



Thanks,
Mandar


srinivasthelu
Tera Guru

The UI action need to be changed into Client Side UI Action.   Below link for more information.



Client & Server Code in One UI Action - ServiceNow Guru