Skip to content

Commit e218791

Browse files
Getting a list of records based on user's location (#1450)
* Create listOfRecordsBasedOnLocation.js * Create Readme.md * Update listOfRecordsBasedOnLocation.js * Update Readme.md * Update Readme.md * Update listOfRecordsBasedOnLocation.js
1 parent c936119 commit e218791

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Get the list of records based on the User's Location while getting the list of records
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Business Rule to display the list of records based on the user's location
2+
3+
When to Run - Before Query
4+
Table - Any table in which you want to perform this script
5+
Scripts -
6+
(function executeRule(current, previous /*null when async*/ ) {
7+
8+
// Add your code here
9+
var current_user = gs.getUserID();
10+
11+
var usr = new GlideRecord('sys_user'); // Query User Table
12+
usr.addQuery('sys_id', current_user);
13+
usr.query();
14+
if (usr.next()) {
15+
if (usr.location != '') {
16+
current.addQuery('location=' + usr.location); // Querying the user's location with current record location
17+
}
18+
}
19+
})(current, previous);

0 commit comments

Comments
 (0)