How to set Timer in workflow

chanikya
Tera Guru

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

find_real_file.png

20 REPLIES 20

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

 

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

what is the condition i should mention in if-condition,

First approval script: 

answer = [];
answer.push(current.u_approver);

in If condition-how to define either first-approval Approved OR not

find_real_file.png

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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';
}

 

find_real_file.png

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader