How to get current record field values

Archana Singh1
Tera Expert

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

1 REPLY 1

Community Alums
Not applicable

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