How to get MRVS variables data?

KoenSmeulders
Tera Expert

We have a scenario where all HR case/RITM variables are saved in the description. The problem is that MRVS variables are show the same as normal variables. (Hopefuly the list shows you what I mean.)

  • Var1: Value
  • Var2: Value
  • MRVSVar1: Value[0]
  • MRVSVar2: Value[0]
  • MRVSVar1: Value[1]
  • MRVSVar2: Value[1]

Now, I'm trying to get the MRVS data dynamically and turn that in to some better-formatted text. the problem I'm facing is that I can find the MRVS variable, but in a ScopedGlideElement form that seems almost useless. The value is readable, but I can't seem to find a way to use it:

 

 [ { "var1" : "Value1", "var2" : "Value1", "var3" : "Value1" }, { "var1" : "Value2", "var2" : "Value2", "var3" : "Value2" } ] 

It looks readable, but I can't parse it to string or JSON, and when I try to look into the ScopedGlideElement, for getRows() I'll just get 0 and 1, and for getQuestionIds(), I'll just get 0, 1 and 2. I can't seem to find anything useable.

 

Any tips?

 

1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage

Hi,

Example Script to Format MRVS Data
:

 

-------------------------------------------------------
var mrvsVariable = current.variables.MRVSVar; 
var rows = mrvsVariable.getValue(); 
var formattedText = '';

try {

var parsedRows = JSON.parse(rows);

parsedRows.forEach(function(row, index) {
formattedText += 'Row ' + (index + 1) + ':\n';
for (var key in row) {
if (row.hasOwnProperty(key)) {
formattedText += key + ': ' + row[key] + '\n';
}
}
formattedText += '\n';
});
} catch (e) {
gs.error('Error parsing MRVS data: ' + e.message);
}


gs.log(formattedText);

Try it and do let me know 

View solution in original post

3 REPLIES 3

Ravi Gaurav
Giga Sage

Hi,

Example Script to Format MRVS Data
:

 

-------------------------------------------------------
var mrvsVariable = current.variables.MRVSVar; 
var rows = mrvsVariable.getValue(); 
var formattedText = '';

try {

var parsedRows = JSON.parse(rows);

parsedRows.forEach(function(row, index) {
formattedText += 'Row ' + (index + 1) + ':\n';
for (var key in row) {
if (row.hasOwnProperty(key)) {
formattedText += key + ': ' + row[key] + '\n';
}
}
formattedText += '\n';
});
} catch (e) {
gs.error('Error parsing MRVS data: ' + e.message);
}


gs.log(formattedText);

Try it and do let me know 

Hello Ravi,

I have one requirement where Amount/ costs are saved in a MRVS column and I want to auto-populate the sum of this amount in another variable. What is the bet way to do it.