- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 10:56 AM
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)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 09:59 PM - edited 08-30-2023 02:00 AM
Hello @Julie Catano ,
Kindly Update your BR with the following details, It will achieve your requirement. Write Before Insert Business rule
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 11:24 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 09:59 PM - edited 08-30-2023 02:00 AM
Hello @Julie Catano ,
Kindly Update your BR with the following details, It will achieve your requirement. Write Before Insert Business rule
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 10:56 AM
This worked thank you so much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 11:44 AM
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.
Regards,
Shyamkumar