- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2015 11:21 AM
Hi guys,
I created a condition in a workflow to wait for assigned tasks to be complete... however the workflow doesn't advance to the next activity after I have done the change on the task record that would allow the next activity to run.
This is what I have one the code.
// Set the variable 'answer' to true or false to indicate if the condition has been met or not.
answer = true;
var gr_tsk = new GlideRecord("change_task");
gr_tsk.addQuery('change_request', current.sys_id);
gr_tsk.addQuery('u_accept_task', '==', 'Yes');
gr_tsk.addQuery('wf_activity', '');
gr_tsk.query();
if (gr_tsk.next()) {
answer = true;
} else {
answer = false;
}
Thanks for your support.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2015 10:46 PM
The wait for script could then be something like this:
var gr_tsk = new GlideRecord("change_task");
gr_tsk.addEncodedQuery('state<3^change_request=' + current.sys_id);
// gr_tsk.addQuery('u_accept_task','Yes'); // I'm not sure/clear why you need this
//gr_tsk.addQuery('wf_activity', ''); // neither sure/clear why you need this.
gr_tsk.query();
if (gr_tsk.hasNext()) {
answer = false; // if there's at least one record open then continue waiting
} else {
answer = true; // if there's no records found then exit the wait for activity
}
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2015 10:25 PM
This is the condition I have for the activity Waitt for condition
//answer = true;
var gr_tsk = new GlideRecord("change_task");
gr_tsk.addQuery('change_request', current.sys_id);
gr_tsk.addQuery('u_accept_task','Yes');
gr_tsk.addQuery('wf_activity', '');
gr_tsk.query();
if (gr_tsk.next()) {
answer = true;
} else {
answer = false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2015 10:41 PM
Hi Jesus, why do you need the following condition:
gr_tsk.addQuery('wf_activity', '');
I believe you don't need it (or at least based on what I understand from what you're trying to accomplish )
Also, if you're looking for all the tasks to be completed then you probably would like an addQuery associated to the state on which you can ask if there's any change task associated to the change request which is not yet closed. If there's any then you could set answer = false; because there's still active tasks for that change request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2015 10:46 PM
The wait for script could then be something like this:
var gr_tsk = new GlideRecord("change_task");
gr_tsk.addEncodedQuery('state<3^change_request=' + current.sys_id);
// gr_tsk.addQuery('u_accept_task','Yes'); // I'm not sure/clear why you need this
//gr_tsk.addQuery('wf_activity', ''); // neither sure/clear why you need this.
gr_tsk.query();
if (gr_tsk.hasNext()) {
answer = false; // if there's at least one record open then continue waiting
} else {
answer = true; // if there's no records found then exit the wait for activity
}
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 06:53 AM
This is not happening, I have task assigned to the change owner to create the task. The wait condition should wait for all tasks to be in u_accept_task 'yes' and continue... next activity. It goes goes to the next activity after the wait condition as soon as the create change tasks has been closed complete.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 07:05 AM
Can you check the wait for completion checkbox in the create task activity? And yes, adding the code I suggested above would work in tandem with the wait for activity.