How to Auto Reject an approval

sk59
Tera Expert

Hi,

Approval should get rejected if it is not approved within 5 minutes. Please let me know how to achieve this?

Thanks in Advance

1 ACCEPTED SOLUTION

Raju Koyagura
Tera Guru

Write a scheduled job and query the sysapproval_approver table to check which are requested 5min back and set the state to rejected.


or


Write set timer (wait/if) conditions on workflow to check the requested time if it is greater than 5min set the state to rejected.





View solution in original post

5 REPLIES 5

Raju Koyagura
Tera Guru

Write a scheduled job and query the sysapproval_approver table to check which are requested 5min back and set the state to rejected.


or


Write set timer (wait/if) conditions on workflow to check the requested time if it is greater than 5min set the state to rejected.





Govind Kumar S1
Kilo Guru

Hi SK,



want to understand , which approvals do you want to auto reject within 5 minutes..specific to Service Request or Change request or you want this functionality to all approvals.



Please elaborate   your requirement so that we can guide you in right direction.



Regards,


Govind Sharma


Hi Govind,



I want for Service Request.



When an order guide is submitted Request is getting created and Approval is attached which is in Requested state. Now I want to move this to Reject if it is not approved within 5 minutes


Hi SK,



In Workflow of service request use the TIMER activity.



Before Approval activity use the TIMER activity and connect it to IF activity.


workflow will wait for 5 mins, if request is not approved then if activity will run the below code and it will cancel the request.



and write the script as



var sr = new GlideRecord('sc_req_item');


sr.addQuery('active', true);


sr.addQuery('state', 'requested');


sr.addQuery('sys_created_on',   '>=',   gs.minutesAgo(15));


sr.query();


if(sr.next())


{


var app = new GlideRecord('sysapproval_approver');


app.addQuery('document_id', current.sys_id);


app.query();


if(app.next())


{


app.state = 'rejected';


}


}



Thanks.


Please test the code before you are using it in your instance.


Hope this might be Helpful