The CreatorCon Call for Content is officially open! Get started here.

How to Auto Close Remediation Tasks

nickt
Tera Contributor

We have a requirement to close any open Remediation Tasks when the parent issue is cancelled. I have created a UI Action which sets the Issue state to Cancelled, and makes it inactive, and tried creating an After Update Business Rule to close the Remediation Tasks.

The UI Action does what it's supposed to, after I added the table to the taskstateUtil script include, but the Business Rule appears to be being simply ignored. - I've tried putting this on both the Issue (sn_grc_issue) and the Remediation Task (sn_grc_task) table, but neither work. - I either get an exception message, or nothing at all happens.

Example of what I've tried copied below.

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

var rtsk = new GlideRecord('sn_grc_task');
rtsk.addQuery('parent', current.sys_id);
rtsk.addQuery('active', 'true');
rtsk.query();
while (rtsk.next()) {
rtsk.state = 4;
rtsk.update();
}
})(current, previous);

 

I've tried changing rtsk.state = 4; to current.state = 4;

Still no luck...

Can anyone help at all?

1 ACCEPTED SOLUTION

Uncle Rob
Kilo Patron

The rule definitely has to be on the Issue table, because that's where the transaction that matters happens.

After Update sn_grc_issue

 

Your script looks ok, so first thing I'd do is be OCD and make sure you have all the columns right.  Does sn_grc_task reference issue via the parent column?  Also be OCD: triple check that 4 is the state you want on the scn_grc_task table.

View solution in original post

3 REPLIES 3

Uncle Rob
Kilo Patron

The rule definitely has to be on the Issue table, because that's where the transaction that matters happens.

After Update sn_grc_issue

 

Your script looks ok, so first thing I'd do is be OCD and make sure you have all the columns right.  Does sn_grc_task reference issue via the parent column?  Also be OCD: triple check that 4 is the state you want on the scn_grc_task table.

nickt
Tera Contributor

Thanks Robert,
It turns out that Parent is the wrong field to reference. It should be issue, so the After Business Rule should look like:

the add query should be:
rtsk.addQuery('issue', current.sys_id)

I also found (and I don't understand the reason for this), that the Business Rule needs to be in the Global application scope, not the GRC Profiles scope.

That is weird about the scope. can you explain further ?