Get display value of variable from hr case variable editor

kali
Tera Contributor

Hi All,

I am using a system property to keep all the variable backend name and passing to a function to get the value , now the problem is while passing from the system property i am passing string as well as reference value, how to get the display value of reference,i am using gliderecord object hrcase. Please help me on this, thanks in advance

hrCase.variables[fieldname];

6 REPLIES 6

Hi @Ankur Bawiskar @Ravi Gaurav @pratikjagtap , I want to access mrvs variable but i am unable to access it , I tried the below code

if (hrCase.next()) {
    var mrvs = hrCase.variables.test_mrvs;

    if (mrvs) {
        gs.info('kalish');
        var rows = mrvs.getRows();
        for (var i = 0; i < rows.length; i++) {
            var row = rows[i];
            var keys = row.getKeys(); // Get all variable names in this row

            gs.info('--- Row ' + (i + 1) + ' ---');
            for (var j = 0; j < keys.length; j++) {
                var key = keys[j];
                var value = row[key];
                gs.info(key + ': ' + value);
            }
        }
    } else {
        gs.info('No MRVS found with variable name: ' + variableName);
    } , I am unable to get the MRVS  value, kindly help me on this

 

@kali 

what's your business requirement?

you can get json key names i.e. variable names using this

if (hrCase.next()) {
    var mrvs = hrCase.variables.test_mrvs;

    if (mrvs) {
        var arr = JSON.parse(mrvs);

        var keyObj = {};
        for (var i = 0; i < arr.length; i++) {
            var obj = arr[i];
            for (var key in obj) {
                keyObj[key] = true; // collect unique keys in an object
            }
        }

        // Convert keys from object to array
        var keyNames = [];
        for (var key in keyObj) {
            keyNames.push(key);
        }

        gs.info(keyNames);

    } else {
        gs.info('No MRVS found with variable name: ' + variableName);
    }

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader