Variable Set with Client Script (onLoad)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:13 AM
Good morning! How do I get a value from within the multirow variable and send it to a variable that is not in the multirow?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:34 AM
Hi @EliaquimS ,
function getMRVSValues() {
var mrvsData = g_form.getMultiRowValues('u_my_mrv_set'); // Assuming "u_my_mrv_set" is the internal name of your MRVS
for (var i = 0; i < mrvsData.length; i++) {
var row = mrvsData[i];
var field1Value = row.u_field1; // Accessing the value of the "u_field1" field in the current row
var field2Value = row.u_field2; // Accessing the value of the "u_field2" field in the current row
// ... perform further operations with the values
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 05:16 AM
This doesn't work my friend!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 05:01 AM
This doesn't work my friend!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:40 AM
Hi @EliaquimS ,
You can use onload client script to auto populate the MRVS data.
function onLoad() {
//Type appropriate comment here, and begin script below
var data = [{
"MaterialID": "10000",
"Description": "Test",
"Quantity": 4
},
{
"MaterialID": "100001",
"Description": "test2",
"Quantity": 1
}
];
// Get the MRVS variable name
var mrvsVariableName = 'product_parameters'; // Replace with your actual variable name
var newRecord = [];
// Loop through the array and add records to the MRVS
data.forEach(function(item) {
// Create a new record in the MRVS
newRecord.push({
"material_id": item.MaterialID,
"description": item.Description,
"quantity": item.Quantity
});
// Push the new record to the MRVS
g_form.setValue(mrvsVariableName, JSON.stringify(newRecord));
});
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 05:20 AM
I don't want to populate my multirow. I want a field filled in my multirow, when filled, to automatically populate another variable that is outside the multirow. Got it?