- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2024 01:18 PM
For use case reasons a string field is required to capture user data.
I need to find sys_id of user record when only data available is a string field with user_name.
I was hoping to accomplish this task as simply as possible, so a Script Includes/Client script is not the direction I want to go in...
I am trying the below script in workflow but the query result is "undefined".
var rqstdFor = current.variables.someUser;
var userGR = new GlideRecord('sys_user');
userGR.addQuery('user_name',rqstdFor);
userGR.query();
var testThis = userGR.query();
gs.addInfoMessage(testThis);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2024 01:55 PM
Hello @Lon Landry4
Use below script
var rqstdFor = current.variables.YOUR VARIABLE NAME;
var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id',rqstdFor);
userGR.query();
if (userGR.next()) {
gs.info('username is :' + userGR.user_name) //replace the field name as per your requirement
}
1.open 'syslog' table.
2.Search with this filter condition ' message contains username is : ' then you can see rqstdFor user_name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2024 05:30 AM
This got me going in the right direction, I still needed to add gr.getValue('sys_id').
But in error I was trying gr.getValue.sys_id