- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 01:03 AM
Hi,
Approval should get rejected if it is not approved within 5 minutes. Please let me know how to achieve this?
Thanks in Advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 01:12 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 03:11 AM
Hi Sk,
For this write one scheduled job as follows:
run: Periodically
repeat Interval : 5 minutes
Conditional : checked
Condition :
var gchg1 = new GlideAggregate('sysapproval_approver');
gchg1.addAggregate('COUNT');
gchg1.addQuery('state','requested');
gchg1.addQuery('source_table','sc_req_item');
gchg1.query();
gchg1.next();
gchg1.getAggregate('COUNT') !== '0';
Run this Script :
var appPending= new GlideRecord('sysapproval_approver');
appPending.addQuery('state','requested');
appPending.addQuery('source_table','sc_req_item');
appPending.addQuery('sys_created_on', '<=' , gs.minutesAgo(5));
appPending.query();
while(chgPending.next()){
var implementDate = new GlideDateTime();
implementDate.setDisplayValue(chgPending.sys_created_on.getDisplayValue()); // Created date time
var todaysDate = new GlideDateTime();
todaysDate.setDisplayValue(gs.nowDateTime()); // Now date time
var resetNum1 = implementDate.getNumericValue();
var todaysNum1 = todaysDate.getNumericValue();
var Age1 = todaysNum1 - resetNum1;
if (Age1 >= 300000 && Age1 <=540000 ){
chgPending.state = rejected ;
chgPending.comments= 'rejected by system by 5 minutes' ; // provide some comments here what ever you like
chgPeding.update();
}
}
Hope this helps you.
Regards,
Govind Sharma
** Please mark correct/Helpful/Like based on impact of answer **