Are you sure message pop-up when resolving Incident that has active children

Carl Fransen1
Tera Guru

Hi Team,

Hopefully a simple one, but I can't figure out how to code this one.  Currently when I press the 'Resolve' UI Action there is automation with a BR that ensures all Children records are updated and also closed.

However - I would like a confirmation message to popup - only if there are active Children, to stay 'This will also resolve the Children, are you sure?' with an 'OK' and 'Cancel'.  If 'OK' is selected the 'Resolve' continues as per normal; if 'Cancel' nothing is done.

The OOTB Resolve code is below:

function resolveIncident(){
	//Set the 'Incident state' and 'State' values to 'Resolved', and display mandatory fields
	g_form.setValue('incident_state', 6);
	g_form.setValue('state', 6);
	g_form.setValue('resolved_by', g_user.userID);
	
	gsftSubmit(null, g_form.getFormElement(), 'resolve_incident'); //MUST call the 'Action name' set in this UI Action
}

//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
	serverResolve();

function serverResolve(){
	current.incident_state = IncidentState.RESOLVED;
	current.update();
	current.resolved_by = gs.getUserID();
}

What I would like to add (I think) is something like this:

var grChild = new GlideRecord("incident");
grChild.addQuery('parent_incident', current.sys_id);
grChild.addActiveQuery();
grChild.query();
if (grChild.getRowCount() > 0) {
 <some message function here>('This Incident has children, resolving this Parent record will also resolve all children');

then abort if cancel.
otherwise continue.

 

But when I add this at the beginning of the 'resolve' script, with a 'gs.addErrorMessage' or 'g_form.showFieldMsg' nothing happens when I click the 'Resolve' button.

Any ideas?

Thanks Carl.

 

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Carl,

You can create a display business rule and then store the response value in scratchpad. Now you can use the scratchpad in UI action to validate whether to show alert or not.

https://docs.servicenow.com/bundle/kingston-application-development/page/script/business-rules/concept/c_ScriptingWithDisplayBusinessRules.html

 

Thanks,

Pradeep Sharma

View solution in original post

8 REPLIES 8

You are very welcome Carl.

 

-Pradeep Sharma

Hi Pradeep/Carl,

@Ankur Bawiskar 

I have a similar kind of requirement with slight add-on things ;

 

Agenda:

 

Upon resolving a major incident, which does not have a problem associated with it in the related record tab, the user will receive a pop-up message saying "The Incident you are trying to resolve is categorized as a Major Incident. To move the incident to resolved state, please action one of the following 3 options:"

The user will be presented with 3 options (with of OK button at the bottom):
1) Create PRB: This will automatically create the PRB (Create Problem button script should be used).
2) Link incident to an existing problem by updating the problem field in the related records tab.
3) Downgrade the incident impact categorization to medium.

-- if there is a PRB already associated with the INC in the Related Records tab within the incident, no pop message will appear and the INC will move to resolved with the already selected priority.

 

Note: Major Incident will be treated as when user selects  below combinations;

of Impact and Urgency within the incident ticket:  

  • 2 -  Impact and 2 - High Urgency
  • 1 -  Impact and 2 - High Urgency
  • 1 -  Impact and 1 - Critical Urgency

 

Appreciate any help on this !..

 

Thanks,

Akshay

Hi Carl,

 

I have a similar kind of requirement with slight add-on things ;

 

Agenda:

 

Upon resolving a major incident, which does not have a problem associated with it in the related record tab, the user will receive a pop-up message saying "The Incident you are trying to resolve is categorized as a Major Incident. To move the incident to resolved state, please action one of the following 3 options:"

The user will be presented with 3 options (with of OK button at the bottom):
1) Create PRB: This will automatically create the PRB (Create Problem button script should be used).
2) Link incident to an existing problem by updating the problem field in the related records tab.
3) Downgrade the incident impact categorization to medium.

-- if there is a PRB already associated with the INC in the Related Records tab within the incident, no pop message will appear and the INC will move to resolved with the already selected priority.

 

Note: Major Incident will be treated as when user selects  below combinations;

of Impact and Urgency within the incident ticket:  

  • 2 -  Impact and 2 - High Urgency
  • 1 -  Impact and 2 - High Urgency
  • 1 -  Impact and 1 - Critical Urgency

 

Appreciate any help on this !..

 

Thanks,

Akshay

Hi Akshay - I'd love to help but unfortunately your request is a bit above my coding skill-set, hoping Pradeep can help, or others such as @Sanjiv Meher or @Ankur Bawiskar ...

 

Cheers

Carl.