- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 04:44 AM
We currently have a Record Producer which creates a Safe Epic record that gets sent over to Azure DevOps. Basically, we write out all the field values entered on the Record Producer to the Description field (as straight text) so it gets sent over to AzDo.
So, for example, we may have the following variables on the Record Producer:
- Submitter (submitter)
- Short Description (short_description)
- Executive Summary (executive_summary)
Then, in the Script section of the Record Producer, we capture these values and write them out to the HTML Description field of the Safe Epic like this:
//capture values from variables
var submitBy = producer.submitter.name;
var shortDesc = producer.short_description;
var execSumm = producer.executive_summary;
//write to HTML Description field of Safe Epic
current.html_description =
'<b> Submitter : </b>' + submitBy + '<br>'+
'<b> Short Description : </b>' + shortDesc + '<br>'+
'<b> Executive Summary : </b>' + execSumm + '<br>';
This all works very well.
However, I have a new twist. We have a Multi-Row Variable Set (MRVS) that is on this Record Producer. I am not sure how to capture the values from this MRVS and write to the HTML Description field, especially since we do not know how many records there will be in the MRVS.
My MRVS looks like this:
So the completed MRVS on the Record Producer may look like this, for example:
Arrangement | Description |
Fully Insured | Some description here |
Self Funded | Some other description here |
Pooled | Something else here |
Can anyone provide some guidance on how I would update my Script to capture these values from the MRVS and write them to the HTML Description field?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 05:02 AM
parse the MRVS json and iterate and concatenate
Something like this and enhance
// Capture values from variables
var submitBy = producer.submitter.name;
var shortDesc = producer.short_description;
var execSumm = producer.executive_summary;
var json = producer.group_funding_arrangement; // Replace with your actual MRVS variable name
var parsedData = JSON.parse(json);
var mrvsData = '<table border="1" style="border-collapse: collapse;"><tr><th>Arrangement</th><th>Description</th></tr>';
for (var i = 0; i < parsedData.length; i++) {
var rowData = '<tr><td>';
var arrangementSysId = parsedData[i].arrangement;
var gr = new GlideRecord("tableName"); // Replace "tableName" with the actual table name
gr.addQuery("sys_id", arrangementSysId);
gr.query();
if (gr.next()) {
rowData += gr.getDisplayValue() + '</td>';
}
rowData += '<td>' + parsedData[i].description + '</td></tr>';
mrvsData += rowData;
}
mrvsData += '</table>';
// Write to HTML Description field of Safe Epic
current.html_description =
'<b> Submitter : </b>' + submitBy + '<br>' +
'<b> Short Description : </b>' + shortDesc + '<br>' +
'<b> Executive Summary : </b>' + execSumm + '<br>' + mrvsData;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 05:02 AM
parse the MRVS json and iterate and concatenate
Something like this and enhance
// Capture values from variables
var submitBy = producer.submitter.name;
var shortDesc = producer.short_description;
var execSumm = producer.executive_summary;
var json = producer.group_funding_arrangement; // Replace with your actual MRVS variable name
var parsedData = JSON.parse(json);
var mrvsData = '<table border="1" style="border-collapse: collapse;"><tr><th>Arrangement</th><th>Description</th></tr>';
for (var i = 0; i < parsedData.length; i++) {
var rowData = '<tr><td>';
var arrangementSysId = parsedData[i].arrangement;
var gr = new GlideRecord("tableName"); // Replace "tableName" with the actual table name
gr.addQuery("sys_id", arrangementSysId);
gr.query();
if (gr.next()) {
rowData += gr.getDisplayValue() + '</td>';
}
rowData += '<td>' + parsedData[i].description + '</td></tr>';
mrvsData += rowData;
}
mrvsData += '</table>';
// Write to HTML Description field of Safe Epic
current.html_description =
'<b> Submitter : </b>' + submitBy + '<br>' +
'<b> Short Description : </b>' + shortDesc + '<br>' +
'<b> Executive Summary : </b>' + execSumm + '<br>' + mrvsData;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 05:19 AM
That works beautifully!
Thank you, Ankur!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 05:27 AM
Glad to help.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader