Skip to content

Commit 32f3d36

Browse files
authored
Update readme.md
This file contains the Script purpose and and how to use this script.
1 parent 798740a commit 32f3d36

File tree

1 file changed

+5
-13
lines changed
  • Scheduled Jobs/Reject approvals created before an year

1 file changed

+5
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
**Creating a GlideRecord Object:**
2-
var grAppr = new GlideRecord("sysapproval_approver");
1+
**Script Purpose:**
2+
This script helps you manage approval records in ServiceNow. It searches for approval requests in the sysapproval_approver table that were created more than 12 months ago and are currently marked as "requested." The script then updates these records to change their status to "rejected."
33

4-
**Adding an Encoded Query:**
5-
grAppr.addEncodedQuery("sys_created_on<javascript:gs.beginningOfLast12Months()^state=requested");
4+
**How to Use This Script**
5+
Where to Run It: You can execute this script in a server-side context, such as a Scheduled Jobs, Script Include, or Background Script. Make sure you have the necessary permissions to access and update records in the sysapproval_approver table.
66

7-
**Executing the Query:**
8-
grAppr.query();
9-
10-
**Iterating Through the Results:**
11-
while(grAppr.next()){
12-
13-
**Updating the State:**
14-
grAppr.setValue('state', 'rejected');
15-
grAppr.update();
7+
**Be Cautious:** The script will automatically find the relevant approval records and update all matching records, so double-check the criteria before executing it.

0 commit comments

Comments
 (0)