How to get display value from MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 03:41 PM
Hi,
I have a MRVS which contains reference variables. When i get the mrvs value i get in json format which contains sys id now how to get the display value instead of sys id ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 03:44 PM
Below has answer
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 04:27 PM
Write a Script include to return a display value. For example, following will return an Array of user name when mvrs with reference variable "user" is sent to script include.
It's usually better to do one call rather than loop in the client script and do multiple calls to the server.
Client Script:
var ajax = new GlideAjax('ConvertJSON2DisplayValue');
ajax.addParam('sysparm_name', 'getDisplayValue');
ajax.addParam('sysparm_mrvs', g_form.getValue('users'));
ajax.getXML(_displayValues);
function _displayValues(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
}
Script Include:
var ConvertJSON2DisplayValue = Class.create();
ConvertJSON2DisplayValue.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDisplayValue: function() {
var mrvs = this.getParameter('sysparm_mrvs');
var userList = JSON.parse(mrvs);
var userNameArray = [];
for (var i = 0; i < userList.length; i++) {
var grUser = new GlideRecord('sys_user');
if (grUser.get(userList[i].user)) {
userNameArray.push(grUser.name.toString());
}
}
return JSON.stringify(userNameArray);
},
type: 'ConvertJSON2DisplayValue'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 04:31 PM
GTW, using GlideRecord at client side is greatly discouraged because it impacts server performance because the entire record is fetched to the client instead of just the necessary column.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 08:34 PM
Hello Irfan,
Instead of reference variable you can use lookup select box variable.
In lookup value field select field name which you want to show in scripting.
In lookup lable field select backend field value of reference field which you want to show on catalog form.
for reference check below screenshot.
Regards,
Harshal.