How to get current record field values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2022 07:22 PM
Hi All,
I am using a display business rule on sys_user table to check for certain roles and then display alert message based on User ID of the opened record.
How can we check the User ID value of the current record?
Regards,
Archana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2022 07:38 PM
Hi Archana Singh,
The below example script has all the details for now and for your future reference:
(function executeRule(current, previous /*null when async*/) {
//var currentUser = gs.getUser(); // I don't think this is needed
var clientDataLog = new GlideRecord('<some_table_name_here>'); //Use your sys_user table
clientDataLog.addQuery();
clientDataLog.query();
while(clientDataLog.next()){ //Please use next() after GlideRecord Query
//clientDataLog.userID = gs.info(currentUser.getUserID()); // you can directly add gs to get the user details
//clientDataLog.username = gs.info(currentUser.getDisplayName()); // gs.info() is to log data in system logs
clientDataLog.userID = gs.getUserID();
clientDataLog.username = gs.getUserDisplayName();
clientDataLog.update();
}
})(current, previous);
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep