Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
>**When a new Approval record (sysapproval_approver table) is created**
1. Create a Before Business Rule on the Approval (sysapproval_approver) table.

2. Check if the table of the record being approved is the Requested For table.

3. If it does:

Verify whether the Approver (approver) is the same as the Opened by (opened_by) field on the related Requested For record.

If both match:

Automatically approve the approval record.

Add appropriate approval comments (e.g., “Auto-approved since approver is the requestor (Opened By).”)

Use setWorkflow(false) to prevent triggering additional workflows or business rules.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(function executeRule(current, previous /*null when async*/ ) {

try {
gs.setWorkflow(false);
if (!current.sysapproval)
return;

// Get the parent record (RITM / REQ / etc.)
var parent = current.sysapproval.getRefRecord();
if (!parent || !parent.isValidRecord())
return;

if (parent.getTableName() == "sc_req_item") {

// Load Opened By user record
var userGR = new GlideRecord("sys_user");
if (!userGR.get(parent.requested_for))
return;


// If approver == Opened By → auto-approve
if (current.approver == parent.opened_by) {
current.state = "approved";
current.comments = "Auto-approved as " + current.getDisplayValue("approver") + " is the manager of Requested For";
current.update();

// Also update parent RITM stage to 'Approved'
parent.stage = "approved";
parent.update();
}
}

} catch (ex) {
gs.error("Auto-approval BR error: " + ex.message);
}

})(current, previous);
Loading