Multi Row Variable Set (MRVS) Not Working on Catalog Task? Here’s What Finally Worked

HarshiniReddy
Tera Contributor

I want to share something that took me way more time than expected to figure out — accessing Multi Row Variable Set (MRVS) data on Catalog Tasks (SCTASK). 


One key confusion point was this: it’s not like normal variables, where simply setting the variables in a variable set to “Global = true” makes them visible on Catalog Tasks. That approach works for many regular variables — but MRVS behaves differently. In fact, MRVS variables can’t be made global at all, so that usual fix won’t help, and you need a different approach.


So posting this here in case it saves someone else a few hours of debugging.


The Problem

When working on a Catalog Task, trying to access MRVS using: 

current.variables.<mrvs_name>

either returns empty or doesn’t behave as expected — because MRVS data is stored differently.

Catalog Tasks don’t directly hold MRVS rows like RITM does.


What Finally Worked for Me

After trying multiple scripting approaches, I implemented an After Insert Business Rule on Catalog Task to map MRVS variables to the task using sc_item_variables_task.

This makes MRVS variables accessible directly at the Catalog Task level.
 

Business Rule Details

  • Table: sc_task
  • When: after insert


Script Used


(function executeRule(current, previous) {

var variables = [];
var catItem = current.request_item.cat_item.toString();
var variableSets = [];
// Get MRVS variable sets linked to catalog item
var getVariableSets = new GlideRecord('io_set_item');
getVariableSets.addQuery('sc_cat_item', catItem);
getVariableSets.addQuery('variable_set.type', 'one_to_many');
getVariableSets.query();

while (getVariableSets.next()) {
        variableSets.push(getVariableSets.getValue('variable_set'));

// Get variables inside MRVS
var getCatalogVariables = new GlideRecord('item_option_new');
getCatalogVariables.addQuery('variable_set.sys_id', 'IN', variableSets.join(','));
getCatalogVariables.addQuery('active', true);
getCatalogVariables.query();

while (getCatalogVariables.next()) {
         variables.push(getCatalogVariables.getValue('sys_id'));
}

// Map variables to catalog task
for (var i = 0; i < variables.length; i++) {
var getTaskVars = new GlideRecord('sc_item_variables_task');
getTaskVars.addQuery('task', current.sys_id);
getTaskVars.addQuery('variable', variables[i]);
getTaskVars.query();

if (!getTaskVars.hasNext()) {
       getTaskVars.initialize();
       getTaskVars.task = current.sys_id;
       getTaskVars.variable = variables[i];
       getTaskVars.insert();
}
}

})(current, previous);


P.S. This is based on what worked for me after quite a bit of trial and error. If anyone has any other working approaches, I’d love to hear them — always happy to learn from the community.

7 REPLIES 7

stevemarkovick
Tera Contributor

Ran into this on a catalog item recently and it turned out to be way less obvious than expected. MRVS looked fine in the UI, but data wasn’t saving because of variable naming and policy order. Double-check client scripts, UI policies, and whether the MRVS is marked mandatory anywhere. Once those conflicts were cleaned up, the rows started persisting normally again.

Hi Steve,

Thank you for taking the time to respond. However, there were no UI Policies or Client Scripts configured initially, and the behavior still did not work as expected.

HarshiniReddy
Tera Contributor

Hi Tanushree,
Thank you for sharing this. However, I was unable to view the MRVS on the task, even after trying across different instance versions, as I initially thought the issue might be due to instance differences.

LynnR0019227730
Tera Expert

Thank you for posting this. It is just what I was looking for and works perfectly.