Action Output: Display Values: Empty output value cannot be blank on publish.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 03:55 PM
Hello, I need help. I would appreciate any help you can give me. I am trying have sysid readable format in a HTML email. Thanks
Script:
(function execute(inputs, outputs) {
// Default output value
outputs.display_values = 'No values selected';
var listCollectorField = inputs.list_collector_field; // List Collector sys_ids
var tableName = inputs.table_name; // Target table name
// Proceed only if the input field has values
if (listCollectorField && tableName) {
var displayValues = []; // Array to hold resolved values
try {
var sysIdArray = listCollectorField.split(','); // Split sys_ids into an array
// Query the table to retrieve the fields
var gr = new GlideRecord(tableName);
for (var i = 0; i < sysIdArray.length; i++) {
if (gr.get(sysIdArray[i])) {
var application = gr.getValue('application') || 'N/A';
var businessApplication = gr.getValue('business_application') || 'N/A';
// Format as "Application: value, Business Application: value"
var formattedValue = 'Application: ' + application + ', Business Application: ' + businessApplication;
displayValues.push(formattedValue);
}
}
// Update the output if display values are found
if (displayValues.length > 0) {
outputs.display_values = displayValues.join('<br>'); // HTML-friendly line breaks
}
} catch (e) {
// Catch errors and set an error message
gs.error('Error in Script Step: ' + e.message);
outputs.display_values = 'Error fetching values';
}
}
})(inputs, outputs);
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 07:16 PM
what's the issue? what debugging have you done so far?
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 07:18 PM
did you print in log what came in the array?
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader