Script for IF 0 tasks in stage "Account Level" move state to complete.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 01:49 PM
Hello, im working in wf editor & i need a script for if there are sc_tasks that contain stage "Account Level" and have 0 tasks, i need the wf to be connected to an activity called "set values" RITM Closed completed. I have the set values, but the script is causing me a headache, can anyone help please or any tips.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 02:06 PM
If this is a workflow then you can just use a "Wait for condition" activity and return false if your script finds the records you are looking for and true if no records found,
//This is what we use in a "Wait for condition" activity.
answer = (function(){
var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.getValue("sys_id"));
gr.addActiveQuery();
gr.query();
if (gr.next())
return false;
else
return true;
})();
If this is for a flow its a bit more involved. For flow designer you need to use a subflow. Here is a screen shot of ours.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 03:05 PM
Hi drew, i have a wait for conditon already to wait for the approver to either approve or send back to prior stage, would i neeed to build this ontop of it? or can i use a script for an IF it has no tasks in account level than to close complete

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2024 08:12 AM
Since I don't know the whole story its difficult to know if you should do that or add another activity. But my first thought is add it after you have decided approval that way its clearer what the workflow is doing.