How do I create an incident from error logging from an import

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 06:49 AM
We have an import that runs daily on a file with all existing workstations. In the onBefore transform script an error is logged if a new workstation is found that can't be coalesced to an existing record.
After the import I want to have an incident with an overview of the error logs so we can check these workstations manually. How do I do this? I have checked existing business rules and onComplete scripts but I cant find what I am looking for.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:00 AM
Hi @Bart Jan Bultma,
Are you using a scheduled import for this?
If so, you can use a post-import script, to query your data and create your incident.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:29 AM
Hello Peter,
Thanks for your answer. We are not using a scheduled import for this, so I was hoping to do this in an onComplete script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:11 AM
As mentioned by Peter you can use Post script
OR
You can also use onComplete transform script and check the current import set to see which rows got ignored because of coalesce value not found or which row has error. then create incident with all this data.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 07:25 AM
Hello Ankur,
Is there an easy/quick way to write these errors into an incident or should I just create a new record on the incident table and fill that as needed? something like this? How do I put the error log in the description?
var gr = new GlideRecord('incident'); gr.initialize(); gr.description = 'Import error'; gr.insert();