Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 06:46 AM
I think siteNameValue is being overwritten with the last characteristic_option_value in the loop (which happens to be pune), causing only that value to be assigned to u_site_name.
(function executeRule(current, previous /*null when async*/) {
var characteristicGR = new GlideRecord('sn_ind_tmt_orm_order_characteristic_value');
characteristicGR.addQuery('sn_ind_tmt_orm_order_task', current.sys_id); // Filter by the current order task
characteristicGR.addQuery('characteristic.name', 'sitename'); // Filter by the characteristic name
characteristicGR.query();
var siteNameValue = ''; // Initialize an empty string to store the concatenated values
// Loop through all the characteristics and concatenate their values
while (characteristicGR.next()) {
var tempSiteNameValue = characteristicGR.characteristic_option_value; // Fetch the characteristic value
if (tempSiteNameValue) {
// concatenate with a comma (or any other delimiter) if it's not the first value
if (siteNameValue != '') {
siteNameValue += ','; // Add a comma separator
}
siteNameValue += tempSiteNameValue; // Append the value
}
}
// If we have any valid site name values, update the u_site_name field
if (siteNameValue) {
current.u_site_name = siteNameValue;
}
})(current, previous);