Scheduled File Import error handling !

Sanjeev Kumar1
Kilo Sage

Hi All,

I have implemented Scheduled File Import it's working.
On Schedule file import screen we have two options.

1. Run Pre-script.
2. Run Post-script.

During data import if there is any problem with schedule Import or if system is not able to import data at same time
we need to implement a way that will generate an e-mail OR create an Incident for admin.
So that admin will able to follow up or fixed that issue before reported by someone.

Please let me know how can we implement it in ServiceNow ?

If you check ( http://wiki.servicenow.com/index.php?title=Scheduling_Data_Imports ).
on wiki we have an option (glide.scheduled_import.stop_on_error = true; ).
But I want some thing like




if(error){
// Sent e-mail
//Or
// Create an incident

}

4 REPLIES 4

Ashu7
Kilo Explorer


Hi ,
I have created a scheduled import using JDBC datasource. It should load all updated records from DB but it is not doing so. Import set is missing random records. Is there any property which I need to set to fix this?

What are the limits, if any, for JDBC data sources for: number of input fields, types of fields, number of records, and/or total amount of data to be imported?


Nick65
Mega Expert

Did you ever have any luck with this?


raj159
Mega Expert

Hi,



I have a similar requirement.



Can some one help me in sending email to admin if there is any problem in loading the data.



Thanks!



Raj


Niclas
Giga Guru

This is a valid questions. In the Post Script you are having access to some fields of the import set. Those variables can be used to query for error messages. You need to walk through the Import Set Runs and the Import Set Error tables:

 

(function() {
        //Get the Latest Import Set Run for the current Import Set
	var gr = new GlideRecord("sys_import_set_run");
        gr.orderByDesc("completed");
        gr.setLimit(1);
        gr.addQuery("set", import_set.sys_id);
        gr.query();
	if (gr.next()) {
                //Check if the Import Set Run has errors
		if (gr.getValue("state") == "complete_with_errors") {
                        //Query the errors
			var grErrors = new GlideRecord("sys_import_set_row_error");
			grErrors.query("run_history", gr.getValue("sys_id"));
			grErrors.query();
			while (grErrors.next()) {
				gs.log("Error: " + grErrors.error_message.getDisplayValue(), "Scheduled Import Error Handling Test");
			}
		}
	}
})();