checking if change tasks have been approved before requesting approval for a change request

donatello
Tera Contributor

I am trying to write a business rule to check all change tickets to make sure that they have been approved before a change can be placed into pending or "requested for approval"". my script is not working for some reason and I would love if the community would help me out. Thanks in advance

function onBefore(current, previous) {

  checkChildTasks();

function checkChildTasks() {

      var grChild = new GlideRecord("change_task");

      grChild.addQuery('change_request', current.sys_id);

      grChild.addQuery('Approval',"CONTAINS","approved");

      grChild.query();

while(grChild.next()){  

      if (grChild.result == "approved" || grChild.result == "skipped")

      answer = true;  

      else{  

      answer = false;  

      return;  

  }  

  }  

}  

}

8 REPLIES 8

here is the screen shot thanks



find_real_file.png


Is this a before business rule and did you check the insert and update checkboxes? Which release are you on?


yes I did here is the snapshot



find_real_file.png


Akshya
Tera Expert

Hi Donatello, were you able to find a solution for this requirement?

 

Thanks,

Akshya