Need help on how to create an additional approval outside of the workflow. (manual request approval)

Julie Catano
Kilo Guru

I'm looking for a way to manually trigger another approval request outside of the workflow.  The requirement is when a sctask is assigned to an assignment group and they need additional approvals on this RITM.  Under the approval tab on the RITM I can see under the drop down "Actions on selected rows" Request approval.  How is this function used, is it like doing an ad hoc approval? and I'm an admin and it's grayed out for me.  (see screen shots)

1 ACCEPTED SOLUTION

Hello @Julie Catano ,

 

Kindly Update your BR with the following details, It will achieve your requirement. Write Before Insert Business rule

 

Sunny3008_0-1693371441967.png

 

 

Before insert business rule

Table: sysapproval_approver
Condition: current.sysapproval.sys_class_name=='sc_req_item'

Script: 
(function executeRule(current, previous /*null when async*/) {
//current.state='requested';    // If you want to add approval as requested state initially add this line otherwise ignore
	// Add your code here
	var gr=new GlideRecord('sc_req_item');
	gr.get(current.sysapproval.sys_id);
	gr.approval='requested';
	gr.update();

})(current, previous);

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

 

View solution in original post

8 REPLIES 8

Hi, I did create a business rule but when I request an approval (see screen shot) and It says it requested approval the RITM still is saying approved.  I'm not sure when you say to replace the fields data with sys_approver where I am getting the information?

Hello @Julie Catano ,

 

Kindly Update your BR with the following details, It will achieve your requirement. Write Before Insert Business rule

 

Sunny3008_0-1693371441967.png

 

 

Before insert business rule

Table: sysapproval_approver
Condition: current.sysapproval.sys_class_name=='sc_req_item'

Script: 
(function executeRule(current, previous /*null when async*/) {
//current.state='requested';    // If you want to add approval as requested state initially add this line otherwise ignore
	// Add your code here
	var gr=new GlideRecord('sc_req_item');
	gr.get(current.sysapproval.sys_id);
	gr.approval='requested';
	gr.update();

})(current, previous);

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

 

This worked thank you so much.

shyamkumar VK
Kilo Patron

Hello @Julie Catano ,

If you want this Approval to be attached Manually , you can utilize following logic in BR on sysapproval_approver table 

var approval_gr = new GlideRecord('sysapproval_approver');
approval_gr.initialize();
approval_gr.state = 'requested';
approval_gr.approver = gs.getUserID();   //Replace with approver from current record
approval_gr.sysapproval = current.sys_id;   //Current is record that requires approval
approval_gr.insert();

The approver and sysapproval columns should be replaced according to your required values.

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar