We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to retrieve Multi-Row (MRVS) values and include them in the RITM or Approval Description

TEJAS
Tera Contributor

Hi Everyone,

I have a requirement to include the values from a Multi-Row Variable Set (MRVS) in either the RITM Description (sc_req_item.description) or the Approval Description (sysapproval_approver.description) when a catalog item is submitted.

I know that normal catalog variables can be accessed using current.variables.<variable_name>, but I'm not sure what the best approach is for MRVS.

My questions 

  1. Has anyone implemented this requirement for populating the RITM description or the approval description with MRVS values?
  2. If possible, could you share your thought 

Any guidance or examples would be greatly appreciated.

Thank you

TEJAS_0-1784266833145.pngTEJAS_1-1784266885468.png

 

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@TEJAS  

data for MRVS is JSON object

So you will have to parse the JSON object and iterate each row and then get the value and set it

check below links with sample code

Populate MRVS Values in RITM Description 

also check below links which talks about grabbing MRVS and showing in email, enhance it for your requirement

How to Display Multi Row Variable set (MRVS) data in a notification 

also check this

Multi-row variable set in Notifications via Notifications Email Script 

Multi-Row Variable Sets: Composing approval and task descriptions 

💡 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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Tera Patron

Hi @TEJAS  

 

Refer:Multi-Row Variable Sets: Composing approval and task descriptions

https://www.servicenow.com/community/developer-forum/populate-mrvs-values-in-ritm-description/m-p/30...

 

You can try this:

You can create an After-Insert Business Rule on the Request Item table (sc_req_item) to parse the JSON rows and update the description field

  1. Table: sc_req_item
  2. When to run: After, Insert
  3. Condition: current.variables.YOUR_MRVS_INTERNAL_NAME != ''

 

(function executeRule(current, previous /*null when async*/) {

    var mrvs = 'YOUR_MRVS_INTERNAL_NAME'; // Replace with your MRVS actual internal name

    var mrvsValues = current.variables[mrvs];

        if (!mrvsValues) return;

    var rows = JSON.parse(mrvsValues);

    var description = '';

 

    for (var i = 0; i < rows.length; i++) {

        description += '--- Row ' + (i + 1) + ' ---\n';

        for (var key in rows[i]) {

            var varSysId = key;

            var gr= new GlideRecord('item_option_new');

            if (gr.get(varSysId)) {

                var label = gr.question_text;

                description += label + ': ' + rows[i][key] + '\n';

            }

        }

        description += '\n';

    }

    current.description = description;

    current.setWorkflow(false);

    current.update();

})(current, previous);

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti