File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Server-Side Components/Background Scripts/Change Approver Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ Safe Approval Reassignment Script — Dummy User
2+ Overview
3+
4+ This ServiceNow background script safely reassigns an approval for a given record.
5+ Instead of directly overwriting the existing approver (which is not recommended), it:
6+
7+ Marks the current approval as “No Longer Required”.
8+
9+ Creates a new approval for a dummy user in the sys_user table.
10+
11+ This approach ensures safe testing, demos, or Hacktoberfest contributions without impacting real approvals or notifications.
12+
13+ Features
14+
15+ Safe & Best Practice: Avoids overwriting existing approvals that may have already triggered notifications.
16+
17+ Dynamic: Can be reused for any parent record by changing parentSysId.
18+
19+ Dummy User: Uses a placeholder user to safely test or demonstrate approval assignment.
20+
21+ Clear Logging: Outputs info/warning messages for easy verification.
22+
23+ How to Use
24+
25+ Create a dummy user in the sys_user table (mandatory).
26+
27+ Update the script with:
28+
29+ parentSysId → sys_id of the record whose approval you want to reassign.
30+
31+ dummyApproverName → Name field of the dummy user in sys_user.
32+
33+ Open Scripts – Background in your ServiceNow instance.
34+
35+ Paste the script and run.
36+
37+ Check the system logs for info/warnings about the reassignment.
38+
39+ Example Output
40+ Existing approval marked as not required for record: d2cdb552db252200a6a2b31be0b8f5ee
41+ New approval assigned to Dummy for record: d2cdb552db252200a6a2b31be0b8f5ee
42+
43+ Notes
44+
45+ Ensure the dummy user exists in the sys_user table; otherwise, the script will warn Dummy user not found.
46+
47+ This script is read-only for the old approval and only modifies workflow safely for testing.
48+
49+ Can be easily extended to handle multiple approvals or multiple dummy users for more complex scenarios.
You can’t perform that action at this time.
0 commit comments