Skip to content

Commit 5e1e232

Browse files
authored
Create sync_integer_field.js
1 parent 81b587d commit 5e1e232

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Business Rule: 'Before' Update on any table that will have a integer field you want to keep in sync
2+
(function executeRule(current, previous /*null when async*/) {
3+
var tableName = current.getTableName()
4+
5+
//This array will contain the list of records with their current value before rearranging them.
6+
var recordList = [];
7+
8+
var tableRecord = new GlideRecord(tableName);
9+
tableRecord.addNotNullQuery({{insert name of integer field you want to sync}}); //Going to exclude records that don't have a value
10+
tableRecord.addQuery('sys_id', '!=', current.sys_id); //Need to exclude the current record
11+
tableRecord.orderBy({{insert name of integer field you want to sync}});
12+
tableRecord.query();
13+
14+
while(tableRecord.next()) {
15+
projectList.push(tableRecord.sys_id.toString());
16+
}
17+
18+
19+
20+
21+
22+
})(current, previous);

0 commit comments

Comments
 (0)