Timer Activity in workflow

Pratiksha Lang1
Kilo Sage

Hi, I have created a workflow where there are 2 level of approvals and for each approval there is 15 days timer. if the first approver doesn't approve of reject within 15 days then the approval should be auto rejected ritm should be closed complete. If the first approver approves it then it should go for second approval based on entity field  it will be assigned to particular group and that group will also have timer of 15 days, if not taken action then approval will be auto rejected and if approved then catalog task will be created accordingly and ritm will be closed complete if all catalog task are completed manually.

 

here is the workflow which I created but it not working as it goes on previous timer and second timer gets cancelled.

 

PratikshaLang1_1-1714376123294.png

 

 

1 REPLY 1

Sujatha V M
Kilo Patron
Kilo Patron

@Pratiksha Lang1  Please find my implementation steps and outline to achieve the use case,

 

1. Created a workflow with 2 approval activities as below.

 

Note: Please add your validations in between. 

 

SujathaVM_0-1714540785787.png

 

2. Create a scheduled job to validate the approval records which where created 15 days ago and reject them. 

Note: For validation, you can click on "Execute Now"  but in reality schedule it for Daily with timelines

 

SujathaVM_1-1714540927755.png

 

Scheduled Job Condition : 

var gr = new GlideRecord('sysapproval_approver');
//gr.addEncodedQuery('state=requested^sysapproval.numberLIKEritm^sys_created_on<javascript&colon;gs.beginningOfLast7Days()^sysapproval.ref_sc_req_item.cat_item=<sys id of your catalog item>');
gr.addEncodedQuery('state=requested^sysapproval.numberLIKERITM^sys_created_onRELATIVELT@dayofweek@ago@15^sysapproval.ref_sc_req_item.cat_item.sys_id=039c516237b1300054b6a3549dbe5dfc');
gr.query();
gr.hasNext();

Scheduled Job Run this script: 

var gr = new GlideRecord('sysapproval_approver');
//gr.addEncodedQuery('state=requested^sysapproval.numberLIKEritm^sys_created_on<javascript&colon;gs.beginningOfLast7Days()^sysapproval.ref_sc_req_item.cat_item=<sys id of your catalog item>');
gr.addEncodedQuery('state=requested^sysapproval.numberLIKERITM^sys_created_onRELATIVELT@dayofweek@ago@15^sysapproval.ref_sc_req_item.cat_item.sys_id=039c516237b1300054b6a3549dbe5dfc');
gr.query();
while(gr.next()){
gr.state = 'rejected';
gr.update();
}

 

Results: 

 

1. First Level Rejection 

SujathaVM_2-1714541209217.png

 

SujathaVM_3-1714541242707.png

On execution of scheduled job, 

 

SujathaVM_4-1714541376837.png

SujathaVM_5-1714541394544.png

 

2. Second Level Rejection

SujathaVM_6-1714541486491.png

 

 

SujathaVM_7-1714541521546.png

On execution of scheduled job, 

 

SujathaVM_8-1714541649255.png

 

SujathaVM_10-1714541678421.png

 

 

Approval will move forward if its done within 15 days, 

 

SujathaVM_11-1714541778627.png

 

SujathaVM_12-1714541798306.png

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.