checking if change tasks have been approved before requesting approval for a change request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 02:03 PM
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;
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 02:05 PM
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;
}
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 02:11 PM
Here you go
function onBefore(current, previous) {
if(checkChildTasks()=="true"){
current.setAbortAction(true);
}
function checkChildTasks() {
var grChild = new GlideRecord("change_task");
grChild.addQuery('change_request', current.sys_id);
grChild.addQuery('approval',"approved");
grChild.query();
if(grChild.hasNext()){
return true;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 04:33 PM
thanks but that did not work, I when I click on request approval it still goes to pending with the change tasks not approved

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 05:14 PM
Can you post the screenshots of your business rule and your business rule conditions