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

Bart Jan Bultma
Kilo Sage

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.

12 REPLIES 12

@Bart Jan Bultma  Correct! 

 

If you need to write a long error log to the incident, then you can consider using a different field, such as the work_notes field. The work_notes field is a plain text field that is not limited to 256 characters.

 

EXAMPLE:

Write the full error log to the work_notes field of the incident:

 

gr.work_notes = log.error();

 

 

You can also use a script to write the error log to a file and then attach the file to the incident. This is a good option if the error log is very long.

 

Write the error log to a file and then attach the file to the incident:

 

// Create a new file.
var file = new GlideFile('error_log.txt');

// Write the error log to the file.
file.write(log.error());

// Attach the file to the incident.
gr.addAttachment('error_log.txt', file);

 

 

Kindly, please mark my solution as Helpful/Correct, if applicable. If I could help you with your Query then, please hit the Thumb Icon and mark as Correct!!!

 

Thanks & Regards, 

Revanth. K

Product Test Automation Engineer

Hello Revanth,

I have tried both the following, but I do not get the information from the error logging into my incident. The incident itself is created with all the parameters I want except the log information.

Am I missing something? 

gr.description = log.error();
gr.work_notes = log.error();

 

@Bart Jan Bultma 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader