How to have a Transform Map Error send an event
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2014 02:25 PM
Most of the time we import our data without an issue. Sometime there is a duplicate key issue. We have set the import to "ignore" so the import completes. This then rely on me to check the log files....
How can I detect an error during a transform an do something like create an event on the event queue. (Too bad there is on "onError" Transform Event Script.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2015 08:53 AM
I just found that you can create an onAfter script that checks the import state for an error like this:
if(source.sys_import_state == 'error')
{
// send a notification or run other script here
}
If there is one you can do whatever scripting you need to do to handle the error or just send a notification. Just remember this runs for each row in the import set, so if you send a notification this way you may end up with a lot of emails. If you can run a script that fixes the error you can change the state to 'pending' and it will try to import the row again. Just add these two lines to the end of your code. Just be careful you don't end up in an infinite loop of trying to fix the error and then retrying to import the row again.
source.sys_import_state = 'pending';
source.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2015 03:01 PM
If it's an email you want when an error occurs you can create a notification (System Policy -> Email -> Notification) on the table the transform map errors write to (Import Set Row Error [sys_import_set_row_error]). Then set conditions on when and what to send within that notification just like you would for incident or other tables.
Or like Stephen McCarty posted, create an onAfter or onReject (I don't think there is an onError) script to create an event if the state is skipped or erred. To create that kind of script navigate to your Transform Map record and at the bottom click on the "Transform Script" tab. Then click "New". From that form select the appropriate "When" choice and write your script which could be as simple as creating a new GlideRecord object for the 'em_event' table.
Of course if you an event with the right type of information you could use setup thresholds so you don't receive so many email notifications.