in servicenow, in screqitem table if approver is the requested for then approval is no…
- User
in servicenow, in sc_req_item table if approver is the requested for then approval is no longer needed
- Assistant
In ServiceNow, when dealing with approvals on the
sc_req_item(Requested Item) table, a common requirement is to skip or automatically approve the approval if the approver is the same as the requested for user.Scenario:
If the approver is the same as the "Requested For" user on the
sc_req_item, then approval should be skipped or automatically set to approved.
How to Implement This
1. Using a Business Rule on the
sysapproval_approvalTableApprovals in ServiceNow are created on the
sysapproval_approvaltable. Each approval record has a reference to the record being approved (document_id) and the approver (approver).You can create a Before Insert Business Rule on
sysapproval_approvaltable that will:- Check if the approval is for a record in
sc_req_item - Compare if the approver is the same as the "Requested For" user on the
sc_req_item - If yes, automatically approve or set the approval state to approved
Example Business Rule Script
Name: Skip Approval If Approver is Requested For
Table:sysapproval_approval
When: Before Insert
Filter conditions: none (check inside script)javascript(function executeRule(current, previous /*null when async*/) { // Only proceed if the approval relates to a Requested Item var doc = current.document_id.getRefRecord(); if (doc.getTableName() == 'sc_req_item') { // Get requested_for user on Requested Item var requestedFor = doc.requested_for; // If approver is the same as requested_for user, auto-approve if (current.approver == requestedFor) { // Set approval state to approved (2 = approved) current.setValue('state', 2); current.comments = 'Auto approved - approver is same as Requested For user'; } } })(current, previous); - Check if the approval is for a record in