How to Show a Popup Message When Some Records Don’t Match During Transform Map Execution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 04:27 AM
Hi
I have added some custom fields to the cmdb_ci table and want to update these fields using a Transform Map while loading data from an Excel file via the Load Data functionality.
My requirement is:
Custom fields should be updated only when the combination of name, ip_address, and serial_number from the Excel file matches an existing record in the cmdb_ci table.
If no match is found, the record should be skipped, and I want to notify the user after the Transform Map runs that some records did not match and were not updated.
Here’s the onAfter script I’m using in the Transform Map:
(function runTransformScript(source, map, log, target) {
var ci = new GlideRecord('cmdb_ci');
ci.addQuery('name', source.u_name);
ci.addQuery('ip_address', source.u_ip_address);
ci.addQuery('serial_number', source.u_serial_number);
ci.query();
if (ci.next()) {
ci.u_custom_field_1 = source.u_custom_field_1;
ci.u_custom_field_2 = source.u_custom_field_2;
ci.update();
} else {
gs.addInfoMessage("No CI match found for name, IP, and serial number for some records. Please check those records.");
}
})(source, map, log, target);
This script works for updating matched records. However, the gs.addInfoMessage() doesn't show up in a popup message after running the Transform Map. I want to alert the user immediately that some records didn't match.
How can I show a popup message or notification after the transform completes if some records were skipped?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 04:36 AM - edited 05-08-2025 04:45 AM
Hello @kurella swamy ,
You can create a event in event registry table and call that event in the else part using
gs.eventQueue('event_name' , ci , 'your reciepient_sys_id', ' ');
Tag this event in your notification that you will create .
One thing i want to highlight here is that this event will be triggered for every mismatched record as onafter script runs after transformation of every import set record.
But if you want only one notification to trigger at the end of the transformation completion you need to shift your logic to on complete script and that too the above script will not work i feel .
In that case you might have you might have to add coalesce for three mappings name, ip_address, and serial_number and if you don't want to insert any records if there is a mismatch you need to ignore the transformation via onbefore script like
if(action=='insert')
{
ignore=true;
}
This would ignore the record which were mismatched and then your on complete script should check for your import set records which are in ignored state and then call a event like above suggested and you need to send the parameter in event and the parameter should contain the array of CMDB record name or some unique display value and you need to catch that event in a email script using event.parm1 and access that array and print the array using template.print and call that email script in your notification to display the array
In this way it will show all the records which are ignored and also triggers only one notification with all the details under one roof
Thanks
Mohith Devatte
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 04:42 AM
Thanks@Mohith Devatte
Actually, my requirement is just to show a message after the transform map runs — not to trigger a notification or email. I initially tried using gs.addInfoMessage() in the onAfter script, but it doesn’t display any message in the UI after the data load completes.
Is there a way to show a simple popup or info message to the user after the transform map finishes processing (especially when some records don’t match)? I'm not looking for an email or notification, just a UI message if possible.
Thanks again for the help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 04:49 AM
@kurella swamy Can you send a screenshot of the UI where you are trying to upload your excel file ?Based on that we can see how to add the UI message because transform map script will not show the message as it runs in back ground
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 05:27 AM
@Mohith Devatte am trying to upload excel file from load data
Here after run the transform map or while checking transform history is there any possibility to show pop up message