I need to create a business rule to auto approve a RITM

Vijayenthiran S
Tera Contributor

Hi All,

 

I want to auto-approve an approval task if the approver is also the Requestor.

 

For example, if the workflow has opened_by manager approval, and now the Manager is submitting a request on behalf of a team member, the RITM should be auto-approved. 

11 REPLIES 11

Peter Bodelier
Giga Sage

Hi @Vijayenthiran S 

 

Below script should work or could be adapted to your use case. But please keep in mind, approvals are there for a reason. So only do this for example if the approver requests something for someone else, but not for himself.

 

(function executeRule(current, previous /*null when async*/) {
var user = current.opened_by.toString();

    var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id',current.sys_id);
gr.addQuery('approver', user);
gr.addQuery('state', 'requested');
gr.query();

if (gr.next()) {

    gr.state = 'approved';
    gr.comments = 'Automagically approved as approver and requestor is the same';
    gr.update();

}
})(current, previous);

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Hi Peter,

 

I tried this but it is not working as expected. In my case, the opened_by and the approver are the same person. But the approval is not auto approving.

Hi @Vijayenthiran S,

 

I think your condition will not work. Try it without a condition first to see if the script works.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

cool, thx

 

Remember that while these services can be helpful, it's important to use them responsibly and ethically. Always review and edit the work you receive to make it your own and avoid academic misconduct. Additionally, consider your budget and deadlines when choosing an essay writing service page, as prices and turnaround times can vary.