Where in the system is Problem Tasks getting closed when Accept Risk is clicked?

TrenaFritsche
Tera Expert

I have a requirement to not close open problem tasks when a problem has the "Accept Risk" button clicked.  This UI Action calls scripts using ProblemModalUIHelpers:

if (g_form && g_form.mandatoryCheck()) {
ScriptLoader.getScripts("ProblemModalUIHelpers.jsdbx", function() {
ProblemModalUIHelpers.onAcceptingRisk();
});
}

I tried to read the UI Script to see if problem tasks were closed from the onAcceptingRisk function, but it doesn't look like it.  I am unable to find where this occurs.  Once I get that figured out, I will be in a better position in deciding how to prevent them from getting closed.  Any help would be much appreciated.

Thanks!

1 ACCEPTED SOLUTION

Hi Trena,

In a baseline instance, I can see that the sys_properties table contains this property - try navigating to this link by replacing ***yourinstance*** with the url for your instance. Otherwise, navigate to the System Properties table by entering sys_properties.list into the Filter Navigator, and search for that property.

The business rule governing the function is found on the Problem table, and is named 'Cascade closure of Problem Tasks', which runs when State = Closed. It's functionality is outlined below:

Condition: gs.getProperty("problem.closed.cancel_open_tasks") == "true"

(function executeRule(current, previous /*null when async*/) {

	var PRB_TASK_CLOSED_STATE = ProblemTaskState.States.CLOSED;
	var problemTaskGr = new GlideRecord("problem_task");
	problemTaskGr.addQuery("problem", current.getUniqueValue());
	problemTaskGr.addActiveQuery();
	problemTaskGr.setValue("state", PRB_TASK_CLOSED_STATE);
	problemTaskGr.setValue("close_code", "canceled");
	problemTaskGr.setValue("close_notes", gs.getMessage("Problem Task is Canceled based on closure of {0}.", current.getDisplayValue()));
	problemTaskGr.updateMultiple();

})(current, previous);

Again, this is the baseline configuration but it is leveraging the system property I referred to, grabbing the state from the ProblemTaskState Script Include, and then iterating against all the records where the problem task is related to the problem.

The mitigation is simply toggling the property from true to false, which will mean the BR won't close the records.

Please let me know if you'd like further clarification.

Kind Regards,

Astrid Sapphire

View solution in original post

8 REPLIES 8

vkachineni
Kilo Sage
Kilo Sage

What happens on the serverside script of the UI action?

Can you post the full script of the UI action if possible.

Thanks

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

That was the entire UI Action Script.  It uses the ProblemModalUIHelpers script Include and here is the function in the script include for Accept Risk:

ProblemModalUIHelpers.onAcceptingRisk = function() {
if (!g_form.hasField("state")) {
getMessage('Cannot accept risk for the Problem as atleast one of the following fields are not visible: \'State\' \'Resolution code\'', function(msg) {
g_form.addErrorMessage(msg);
});
return false;
}

var sysId = g_form.getUniqueValue();
var moveToClosed = g_scratchpad.PROP_MOVE_TO_CLOSED;
var stateValue = moveToClosed == 'true' ? g_scratchpad.STATE.CLOSED : g_scratchpad.STATE.RESOLVED;
g_form.setValue("state", stateValue);
g_form.setValue("resolution_code", g_scratchpad.RESOLUTION_CODES.RISK_ACCEPTED);
if (g_form.mandatoryCheck()) {
g_form.save();
return;
}

g_form.clearMessages();
var formValues = {
state: stateValue,
resolution_code: g_scratchpad.RESOLUTION_CODES.RISK_ACCEPTED
};
var ob = new ProblemModalUIHelpers();
ob.openModal("accept_risk_dialog_form_view", getMessage('Accept Risk'), 900, formValues);
};

 

As you can see in the lines

 

var moveToClosed = g_scratchpad.PROP_MOVE_TO_CLOSED;

var stateValue = moveToClosed == 'true' ? g_scratchpad.STATE.CLOSED : g_scratchpad.STATE.RESOLVED;

 

If moveToClosed is true then set the form fields and save the form.

Now We need to find out where the scrachpad property is getting set for

g_scratchpad.PROP_MOVE_TO_CLOSED

 

If you look at the BR

Set State variables on Scratchpad

g_scratchpad.PROP_MOVE_TO_CLOSED is using the property

problem.acceptrisk.move_to_closed

 

Do a sys_properties.LIST and look for the name 

problem.acceptrisk.move_to_closed

 

Setting that to false will not close the problems

 

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Hi,

This refers to why the problem closes, not the problem tasks as the OP requested. My explanation below explains that, and it works in concert with the property mentioned here.

Doing both in concert would mean that the problem moves to Resolved as opposed to Closed, and the Problem Tasks would not close, even when the Problem moves from Resolved to Closed.

Kind Regards,

Astrid