Reset or resend approval email

Darren22
Tera Expert

Morning,

I have a requirement to send out a reminder approval after 7 days if the first approval has not been actioned. 

Background: We have a request on the SSP which allows users to deploy devices to our customers and part of workflow requires the users to approve a certain part. What we are finding is that people are just ignoring the approval email. So I have been asked that after 7 days if the approval email hasn't been action, send out a reminder notification along with an approval email.

Issue: I have tried to research possible solutions and I'm just struggling to find one. I thought about just sending out another approval and then having the two approvals link up but business aren't exactly happy with this approach.

I thought about a scheduled job but not sure how you identify to resend approvals only for approvals relating to that one type of request.

If someone could maybe just point me in a direction that would be excellent or how did you resolve something similar.

Thanks

1 REPLY 1

shill
Mega Sage

I assume this is for a particular item in your catalog?  You should be able to dot walk to the approval for record and query against that particular item.  At my past employer, we had something similar where we sent approval reminders after 4 days, then after 12 days a second reminder, then anything older than 16 days was auto rejected.  The code below is what I used.  Hopefully that can give you an idea on how you can accomplish your goal.  This was a scheduled job that ran every morning (weekdays) at 7am.

getFirstReminder();
getSecondReminder();
RejectApproval();


function getFirstReminder(){
	var gr = new GlideRecord('sysapproval_approver');
	// query for procurement items that are over 4 days old
	var querystring = "state=requested^sysapproval.sys_class_name=sc_req_item^iteration=1^sys_created_onRELATIVELT@dayofweek@ago@4";
	gr.addEncodedQuery(querystring);
	gr.query();
	while (gr.next()) {
		gs.eventQueue('requested_item.approval.reminder1', gr, gs.getUserName(), gr.approver.name);
		gr.iteration +=1;
		gr.comments = "First approval reminder sent";
		gr.update();
	}
}

function getSecondReminder(){
	var gr = new GlideRecord('sysapproval_approver');
	// query for procurement items that are over 12 days old
	var querystring = "state=requested^sysapproval.sys_class_name=sc_req_item^iteration=2^sys_created_onRELATIVELT@dayofweek@ago@12";
	gr.addEncodedQuery(querystring);
	gr.query();
	while (gr.next()) {
		gs.eventQueue('requested_item.approval.reminder2', gr, gs.getUserName(), gr.approver.name);
		gr.iteration +=1;
		gr.comments = "Second approval reminder sent";
		gr.update();
	}
}

function RejectApproval(){
	var gr = new GlideRecord('sysapproval_approver');
	// query for procurement items that are over 16 days old
	var querystring = "state=requested^sysapproval.sys_class_name=sc_req_item^iteration=3^sys_updated_onRELATIVELT@dayofweek@ago@4";
	gr.addEncodedQuery(querystring);
	gr.query();
	while (gr.next()) {
		//gs.eventQueue('requested_item.approval.reminder2', gr, gs.getUserName(), gr.approver.name);
		gr.iteration +=1;
		gr.state = 'rejected';
		gr.comments = "Automatically rejected after 16 or more days of inactivity";
		gr.update();
	}