- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 02:49 PM
Hello community I need help:
I need to close a task in a workflow after 5 minutes (I attached a reference photo, please see it). I have read that you can use a timer, wait for condition and set value, but I don't know how to use them so that the first task closes after 5 minutes. Please I need a graphic answer (step by step) so I can achieve this. Thank you very much.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 07:29 PM
Hi,
We can achieve this use case with either of following ways ;
- Write a BR on same catalog item task [ sc_task ] table and closed the Task with difference of 5 minute using some current date/time calculation or using gs.sleep(millisecond);
- Write another workflow on RITM [ sc_req_item ] for same catalog item [ item ] and check the first task and close after [5minute] once the first task closed the main workflow will create next task.
- Update your current workflow and add the timer & first task as same level and add run script after timer and run script will close the first task , after run script execution complete the second task will trigger.
I tested the 3rd option and it's working as per your requirement.
Timer TIme = 5 minutes
Run Script Code :
Run Script :
var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item',current.sys_id); // request_item is RITM reference column in sc_talk table;
gs.log('request_item='+current.sys_id);
grTask.addQuery('active' , true); // check if task is still open
grTask.query(); //execute the query
// check if result set has some task record
if(grTask.next()){
grTask.state = '3' ; // 3 is choice value for close complete
grTask.comments ='Task closed by 5minute timer';
grTask.update();
}
Please review & test and let us know if this design is working for you.
Thanks,
Ashish
Please mark correct answer and helpful for others if it helps you.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2020 07:29 PM
Hi,
We can achieve this use case with either of following ways ;
- Write a BR on same catalog item task [ sc_task ] table and closed the Task with difference of 5 minute using some current date/time calculation or using gs.sleep(millisecond);
- Write another workflow on RITM [ sc_req_item ] for same catalog item [ item ] and check the first task and close after [5minute] once the first task closed the main workflow will create next task.
- Update your current workflow and add the timer & first task as same level and add run script after timer and run script will close the first task , after run script execution complete the second task will trigger.
I tested the 3rd option and it's working as per your requirement.
Timer TIme = 5 minutes
Run Script Code :
Run Script :
var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item',current.sys_id); // request_item is RITM reference column in sc_talk table;
gs.log('request_item='+current.sys_id);
grTask.addQuery('active' , true); // check if task is still open
grTask.query(); //execute the query
// check if result set has some task record
if(grTask.next()){
grTask.state = '3' ; // 3 is choice value for close complete
grTask.comments ='Task closed by 5minute timer';
grTask.update();
}
Please review & test and let us know if this design is working for you.
Thanks,
Ashish
Please mark correct answer and helpful for others if it helps you.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2020 03:34 PM
THANK YOU VERY MUCH!!! I tried the option you gave me and it worked !!! thank you from the bottom of my heart, you are my hero!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2020 03:40 PM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 05:35 AM
To first option: Never ever use gs.sleep() in your business rules. It is not best practice. It affects whole server, so it can cause performance issues.
If business rule need to be postponed, use scheduled event and trigger a script action with this event.