Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Kalaiarasan Pus
Giga Sage

It has been asked multiple times in different questions on the community, on how to get the display value of a multirow variable set. While there are different ways to do this, the easiest of them is to leverage an out of box script named 'VariableUtil'. 

The script is present in the global scope and contains an function named getDisplayValue aptly. This function seems to work on both the normal variable as well as multirow variableset. You just need to pass the sysid of the variable or the multirow variableset and its corresponding value.

new VariableUtil().getDisplayValue('sys_id of variable or MRVS','value of variable/MRVS');

Depending on whether the input is a standalone variable sysid or a multiple row variableset, the return value is either a single value or a an object array.

Below sample script can be used to test the functions. Change the sysid's as per your setup.

var script = new global.VariableUtil();
var gr = new GlideRecord("sc_req_item");
gr.addEncodedQuery("number=something");
gr.query();
if (gr.next()) {
    gs.info(gr.variables.MRVSName); // MRVS Value
    gs.info(script.getDisplayValue('MRVS Variableset SYSID', gr.variables.MRVSName)); //MRVS Display Value
}

I hope you found this short blog useful.

Note: I was not able to find any reference to this script on community while searching. If someone has already talked about this, I would be happy to link the reference to this blog.

Edit: Found another user answering about VariableUtil in an old thread, which can be found here

2 Comments