- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2016 05:42 PM
Script for my IF activity in the workflow:
answer = ifScript();
function ifScript() {
if (sc_task.u_separation_verification == 'Approved') {
return 'yes';
} else {
return 'no';
}
}
Workflow table is sc_req_item.
How can we refer to the sc_task table for the value in the workflow?
Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2016 07:10 PM
Hi Ruey,
The above script pasted by Abhi should work. I am assuming there will be only one task out of many which has assignment group "Service B". If yes then you can add an additional query based on assignment group.
Additional things to be modified in above code.
- Change line from the above code to make it work i.e gr.addQuery("parent",current.sys_id); should be gr.addQuery("request_item",current.sys_id);
- There is a typo error in above code i.e function getTaskInfo()[ should be function getTaskInfo(){
Hence the final code will be
answer = ifScript();
function ifScript() {
if (getTaskInfo()== 'Approved') { //Make sure Approved is the exact choice value
return 'yes';
} else {
return 'no';
}
}
function getTaskInfo(){
var gr = new GlideRecord('sc_task');
gr.addQuery("request_item",current.sys_id);
// add another addQuery condition to filter the exact task you are looking for, this can be based on the task's property...
gr.addQuery("assignment_group.name", 'Service B'); //Make sure Service B is the exact name of the group
gr.query();
if(gr.next()){
return gr.getValue("u_separation_verification");
}else{
return -1;
}
}
Please let us know if you have any additional question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2016 07:10 PM
Hi Ruey,
The above script pasted by Abhi should work. I am assuming there will be only one task out of many which has assignment group "Service B". If yes then you can add an additional query based on assignment group.
Additional things to be modified in above code.
- Change line from the above code to make it work i.e gr.addQuery("parent",current.sys_id); should be gr.addQuery("request_item",current.sys_id);
- There is a typo error in above code i.e function getTaskInfo()[ should be function getTaskInfo(){
Hence the final code will be
answer = ifScript();
function ifScript() {
if (getTaskInfo()== 'Approved') { //Make sure Approved is the exact choice value
return 'yes';
} else {
return 'no';
}
}
function getTaskInfo(){
var gr = new GlideRecord('sc_task');
gr.addQuery("request_item",current.sys_id);
// add another addQuery condition to filter the exact task you are looking for, this can be based on the task's property...
gr.addQuery("assignment_group.name", 'Service B'); //Make sure Service B is the exact name of the group
gr.query();
if(gr.next()){
return gr.getValue("u_separation_verification");
}else{
return -1;
}
}
Please let us know if you have any additional question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2016 07:30 PM
Thanks so much Pradeep.
It is working now.