Convert the Sys id to string for multirow variable set fields in arecord producer how to achieve ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 08:29 PM
Hello Everyone,
We have a requirement where we need to reference all the record producer fields in a specific field called the "Details Section." Within this section, we are using a MultiRow Variable Set. However, we are encountering an issue when trying to convert a sysid to a string, particularly when the field is a reference field linked to the sysuser table. Although we attempted to use the getDisplayValue() method and tried converting it to a string, the entire value disappears from the record producer's Details Section when we do so. I would appreciate any guidance or assistance you could provide to help us resolve this issue. Please refer to the attached screenshot for further context. Thank you in advance for your support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 10:19 AM
Are you trying to get the user name field instead of the sys_id? In your screenshot, it looks like you have the sys_id. Can you share your code that is pushing this data into the details section?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 06:14 PM
here we are getting all the fields details except reference fileds .I have created one more field with single line and given the reference filed as dependent their we are getting the result but now I am planning to hide the sys id filed how to achieve this method please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 07:15 PM
purchasing_details is MRVS
So it will give you json string.
you need to parse it and get the values.
Remember it will give sysId for reference and list collector within MRVS. You will have to use explicit GlideRecord to get the display value by querying the table with that sysId
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 07:43 PM
Please use this code as reference
(function() {
// JSON input
var purchasing_details = [{
"sys_id": "2823923339303"
}];
var sysId = purchasing_details[0].sys_id;
// GlideRecord to fetch user details
var userGR = new GlideRecord('sys_user'); // sys_user table
if (userGR.get(sysId)) {
var userLocation = userGR.location.getDisplayValue(); // Fetch Location
var userDepartment = userGR.department.getDisplayValue(); // Fetch Department
// Output the details
gs.info("User Location: " + userLocation);
gs.info("User Department: " + userDepartment);
} else {
gs.info("User not found for sys_id: " + sysId);
}
})();