in servicenow background script, var callerID = '62826bf03710200044e0bfc8bcbe5df1'; var…
- User
in servicenow background script,
var callerID = '62826bf03710200044e0bfc8bcbe5df1'; var caller = new GlideRecord('sys_user'); if (caller.get(callerID)) { var manager = caller.manager.getDisplayValue();
var location = caller.location.getDisplayValue(); var department = caller.department.getDisplayValue();gs.info('Manager: ' + manager); gs.info('Location: ' + location); gs.info('Department: ' + department);}
- Assistant
Your script is mostly correct for retrieving the manager, location, and department display values for a specific user record in ServiceNow using a background script.
Explanation:
caller.get(callerID)loads the user record.caller.manager.getDisplayValue()fetches the display value of the manager (which is a reference field).- Similarly for location and department.
One thing to note:
Make sure that
manager,location, anddepartmentare reference fields in thesys_usertable (which they typically are by default).