Issue with Appending MRVS Data to Record Description

kanvapuriga
Tera Contributor

Hi All,
I have created a Record Producer that includes a Multi-Row Variable Set (MRVS). My objective is to automatically append the values from the MRVS to the record's description field upon submission of a request.
I attempted to achieve this using an "After Insert" Business Rule; and also from Reocrd producer script section-->however, the variables within the MRVS are not being appended as expected.
Could anyone please guide me on how to implement this functionality effectively?
Thank you in advance for your support.

3 REPLIES 3

Kieran Anson
Kilo Patron

Could you share the code you've written for your record producer script? That way, we can review and provide advice on what might be the issue

M Iftikhar
Tera Sage

Hi @kanvapuriga,

You can achieve this by using a Record Producer Script that retrieves the rows from your Multi-Row Variable Set (MRVS), iterates through each row, and then appends those values to the description field of the generated record (e.g., an incident or a sc_request).

var mrvsName = "mobile_devices_set"; // Replace with your MRVS variable set name
var mrvsVariables = {                // Map display labels to MRVS field names
    "Device Type": "device_type",
    "Storage": "storage",
    "Color": "color",
    "Quantity": "quantity"
};

var mrvs = JSON.parse(producer[mrvsName]);
var mrvsDetails = generateMrvsDetails(mrvs, mrvsVariables);
current.description = (current.description || '') + '\n--- Mobile Devices ---\n' + mrvsDetails;

// Function to generate MRVS details string
function generateMrvsDetails(mrvsArray, variablesMapping) {
    if (!mrvsArray || mrvsArray.length === 0) {
        return '\n(No entries provided in the MRVS)\n';
    }

    var details = '';
    for (var i = 0; i < mrvsArray.length; i++) {
        var row = mrvsArray[i];
        details += '\n--- Entry ' + (i + 1) + ' ---\n';
        for (var label in variablesMapping) {
            var fieldName = variablesMapping[label];
            details += label + ': ' + (row[fieldName] || '') + '\n';
        }
    }
    return details;
}

You can also move generateMrvsDetails function to a separate script include if you want to use this in multiple record producers.

MIftikhar_1-1761217294149.png

 


MIftikhar_0-1761217272536.png

 If my response helped, please mark it as the accepted solution so others can benefit as well.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Ankur Bawiskar
Tera Patron
Tera Patron

@kanvapuriga 

this is a duplicate thread.

I already shared solution/approach in your other thread.

Issue with Appending MRVS variables to Record Description 

💡 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