- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
I am working on a workflow script to take a Multi-Row Variable Set from a catalog item. Create an array to get the data so that I can transfer the display name of the field POAM to a CHG. Everything is working great for creating the CHG from the catalog item, except for this one last piece. The POAM field on the CHG form is a string field and I just need the POAM IDs, not the other information.
Here is the section of code.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @erin-marie ,
use this updated code:
var poamArr = [];
var poamField = current.variables['decommission_poam_details'];
var rowCount = poamField.getRowCount();
// Iterate through each row in the MRVS
for (var i = 0; i < rowCount; i++) {
var row = poamField.getRow(i);
var poamId = row.sc_decomm_poam_id;
// Check if POAM ID exists
if (poamId) {
var gr = new GlideRecord('u_poam');
if (gr.get(poamId)) {
poamArr.push(gr.getDisplayValue()); // Add display value to array
}
}
}
// Assign to CHG field if array has values
if (poamArr.length > 0) {
change.u_poa_m_ids = poamArr.join('\n');
}
To extract POAM IDs from a Multi Row Variable Set and transfer them to a Change Request (CHG) in ServiceNow, initialize an empty array to store the POAM display values, iterate through each row in the MRVS to retrieve the POAM ID, query the u_poam table using GlideRecord to fetch the corresponding record, extract the display value, and append it to the array; finally, assign the concatenated display values to the u_poa_m_ids field in the CHG, separated by newlines.....
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hello,
Your poam_arr is showing empty in the log so you need to look at the GlideRecord. Is your u_poam table in the Global or same scope as the Catalog Item? When pushing the value to the poam_arr I think you meant:
poam_arr.push(gr.getDisplayValue());
If this doesn't show values in the third / poam_arr log, add a log within the if block of the GR to make sure a record is found. Once you've confirmed this, try something more like:
poam_arr.push(gr.getValue('u_name'));
or whatever your display value field name is on this table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @erin-marie ,
use this updated code:
var poamArr = [];
var poamField = current.variables['decommission_poam_details'];
var rowCount = poamField.getRowCount();
// Iterate through each row in the MRVS
for (var i = 0; i < rowCount; i++) {
var row = poamField.getRow(i);
var poamId = row.sc_decomm_poam_id;
// Check if POAM ID exists
if (poamId) {
var gr = new GlideRecord('u_poam');
if (gr.get(poamId)) {
poamArr.push(gr.getDisplayValue()); // Add display value to array
}
}
}
// Assign to CHG field if array has values
if (poamArr.length > 0) {
change.u_poa_m_ids = poamArr.join('\n');
}
To extract POAM IDs from a Multi Row Variable Set and transfer them to a Change Request (CHG) in ServiceNow, initialize an empty array to store the POAM display values, iterate through each row in the MRVS to retrieve the POAM ID, query the u_poam table using GlideRecord to fetch the corresponding record, extract the display value, and append it to the array; finally, assign the concatenated display values to the u_poa_m_ids field in the CHG, separated by newlines.....
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
This worked perfectly. Thank you so much!!!