Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to cancel open child tasks when change request is closing

sriram7
Tera Contributor

Hi Team,

 

How to cancel open child tasks when change request is closing

 

I have written After Update Business rule, 

 

Condition: current.state == 3 && current.state.changes()

 

Script:

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

    // Add your code here
    abortcanc();

function abortcanc() {
  if (current.sys_id == '') {
    gs.info("Business Rule: Sys_ID is empty. Exiting.");
    return;
  }

  var gr = new GlideRecord('change_task');
  gr.addQuery('parent', current.sys_id);
  gr.query();

  while (gr.next()) {
    if (gr.active == true) {
      gr.state = 4;
      gr.update();
      gs.info("Business Rule: Updated Change Task " + gr.number + " associated with Change Request " + current.number);
    }
  }
 
However code is not working,
 
Can you please help me with this
2 REPLIES 2

Uncle Rob
Kilo Patron

Don't script this.   Flow Designer should be able to do that, codeless.

 

TRIGGER:   On Change Request state changes and state = 3
1 - Look up records on change_task where parent is the trigger record
2 - For each of (1)
3 - Set State = 4


Uncle Rob
Kilo Patron

Also, you no longer need lines like this:

gs.info("Business Rule: Sys_ID is empty. Exiting.");

 

Check out this video I did on the system log context map