Wait For Condition Not Working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2022 08:45 AM
I have a variable that is hidden on the RITM but is visible and mandatory on the SCTASK. The user selects yes or no and if the user selects yes the workflow should move on from the wait for condition. After doing some research I realized that the workflow is running on the sc_req_item table and the variable update is on the sc_task table. So I found a business rule to force an update for the workflow to continue which is below
(function executeRule(current, previous /*null when async*/ ) {
// force update of RITM when catalog task is closed.
var grRitm = new GlideRecord('sc_req_item');
grRitm.get('sys_id', current.request_item);
grRitm.setForceUpdate(true);
grRitm.update();
})(current, previous);
then in the wait for condition activity I put the following code -
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.sys_id);
gr.addQuery('short_description', 'CONTAINS', 'Order New Services');
gr.query();
if (gr.next()) {
if (gr.getValue('need_to_upload_the_service_agreement_or_contract') == 'Yes') {
workflow.info('MACD Answer=True');
answer = true;
return answer;
} else {
workflow.info('MACD Answer=False');
answer = false;
return answer;
}
}
return answer;
}
I've tried just doing a simple if statement, like below
if(current.variables.need_to_upload_the_service_agreement_or_contract == 'Yes') {
answer=true;
}else{
answer=false;
}
and that isn't working as well. What am I missing here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2022 09:27 AM
The second is the way to go, or just build it in the Condition so you don't have to worry about getting the variable name or value vs labels correct:
Variables <<your catalog item>> <<yes/no variable>> is Yes
So your workflow is entering the Wait for activity in parallel with the Catalog Task? If the workflow waits for the task to be completed and this variable is mandatory, then you wouldn't need a wait for activity at all. After the task is completed and Yes was selected the executing context still shows the Wait for activity as executing?
Variables are stored as an object which is accessible from the sc_task and sc_req_item record, so there's only one true value to a variable, and it's not stored on either table but both records see an 'update' when a variable value changes, so that's why you don't need a Business Rule or the first wait for script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2022 09:31 AM - edited ‎11-22-2022 09:32 AM
So the wait for completion box is not checked on this catalog task. The ask was the ability to be able to add an adhoc task on the fly. The user selects yes or no for needing to add one. If they select yes then it generates that task. If they select no it moves to the Wait for all tasks to be completed wait for activity. I had it working with if statements and looping through until there was either a yes or no value for the variable. The issue with that is performance, it kept maxing out at 100 activities and yes we can increase the limit there. However, that is where the potential performance impact comes into play. So I figured if I do a wait for activity and have it wait for the variable to be yes or no then I could do it that way. But the wait for activity is not working at all. Even with it just being the second option I listed above, the wait for activity just keeps staying in a running state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2022 09:39 AM
It sounds like you would want the wait for condition or script to be more like that variable is not empty (!=''), then an if activity to evaluate whether the task is needed. If you temporarily unhide the variable on the RITM you'll see that when it is populated on the Catalog Task that same value will be reflected on the RITM, so that should be enough to move the workflow forward. With the updated wait for logic, if this is still not happening, try manually updating something, anything on the RITM to see if it continues after that update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2022 10:09 AM - edited ‎11-22-2022 10:13 AM
Still a no go, tried even unchecking wait for completion on all the SCTASKs in this path on the workflow, also tried just using the condition builder and it just stays running -