How to set Timer in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2019 06:25 AM
Hi
i have request like this,
if 1st - approval didn't approved with in 1-day , then goto setValue "Cancelled"--End
if approved with in 1-day , goto 2nd- approval , if 2nd approval didn't approved with in 1-day, then goto setValue "Cancelled"--End.
if TWO approvals approved with in 1-day then goto Setvalue-" complete"---END.
So how should i use timer here...???
The Workflow is on Custom Table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2019 09:13 AM
Hi Chanikya,
you told that you want to wait for 10mins for first approval; which I believe is working fine
I believe this is your question;
the timer activity was running in background for 2mins for 1st approval and once it crossed 2 mins it should check whether the 1st approval is approved or not
if yes then do nothing; if not then cancel the request
but here since no check after 2mins timer it directly went to set values and workflow got to end
if that is the case then add if condition to check whether first level of approval is approved or not; if activity has 2 outputs yes and no;
yes will take to another activity
no will take to set values for cancel request and then workflow ends
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 02:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 03:03 AM
Hi Chanikya,
So you are query the sysapproval_approver table and orderByDesc on created on field.
so you would get 1st approval record i.e. record which got created first
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 03:25 AM
can you help me , is it correct ?
answer = ifScript();
function ifScript(){
var app=new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval', current.sys_id);
app.orderByDesc('sys_created_on');
app.addQuery('state','requested');
app.query();
if(app.next())
{
return 'yes';
}else
{
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2019 04:04 AM
Hi Chanikya,
update code as below:
answer = ifScript();
function ifScript(){
var app=new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval', current.sys_id);
app.addQuery('state','requested');
app.orderByDesc('sys_created_on');
app.query();
if(app.next())
{
return 'yes';
}else
{
return 'no';
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader