Scheduling Data Imports

From ServiceNow Wiki
Home > Administer > Managing Data > Import Sets > Scheduling Data Imports (Redirected from Import Sets Scheduled Imports)
Jump to: navigation, search

1 Overview

Scheduled Imports make it is possible to specify that certain import operations should occur at some regular interval. If a remote datasource is chosen, it will be refreshed via the remote connection prior to the import operation. To create a Scheduled Data Import, navigate to System Import Sets > Administration > Scheduled Imports.

Note
Note: Do not schedule multiple imports at the same time. Running multiple imports concurrently may negatively impact performance or cause an instance outage.


Sample Schedule Data Import record

Field Description
Name Enter a name for this scheduled data import.
Data source Enter the origin of the data to be imported.
Run as Enter the name of a user whose credentials the import job will use. If you do not specify a value, the import job runs as the guest user.
Active Select this check box to activate the scheduled import.
Run Select the frequency that you want to run the import.
Time Enter the time you want the import to begin. Do not schedule multiple imports at the same time. Running multiple imports concurrently may negatively impact performance or cause an instance outage.
Conditional Select this check box if you want to write a script to define the conditions that must evaluate to true before the import will run.
Condition Write the script to be used to evaluate whether an import should run. This field is visible if you selected the Conditional check box.
Repeat interval Select the period of time that must elapse before the import will be repeated. This field is visible if Run is set to Periodically.
Starting Click the calendar icon and select the date on which the import should begin. This field is visible if Run is set to Periodically.
Execute pre-import script Select this check box if you want to write a script to be run before the import is performed.
Pre-script Write the script you want to run before the data is imported. This field is visible if you selected the Execute pre-import script check box.
Execute post-import script Select this check box if you want to write a script to be run after the import is performed
Post script Write the script you want to run after the import finishes. This field is visible if you selected the Execute post-import script check box.

2 Scripting Options

Scheduled Import Pre and Post scripts have access to the following JavaScript objects:

Object Description
cancel Set this object to true to stop the import action.
glide.scheduled_import.stop_on_error Set this object to true to stop the import process when the parent scheduled import generates an error
import_set Get the GlideRecord object for the new import set. This variable allows you to query the following columns from the sys_import_set table (Fuji release):
  • number
  • sys_id
  • state
  • table_name
data_source Specify the data source you want the scheduled import to use.The data source must be an existing GlideRecord object.

2.1 Cancelling Out of a Scheduled Import

Use the Pre-script field to evaluate the conditions of the import and determine whether to cancel the import process. To cancel the import process, use the following call.

cancel = true;

2.2 Canceling dependent Scheduled Imports

One import set can depend on the results of another import set. Use the following code to stop the current import set when the parent import set generates an error.

glide.scheduled_import.stop_on_error = true;

2.3 Querying the New Import Set Created by the Scheduled Import

If you want to use information from the import set, you can specify one of the properties of the import_set variable.

var x = import_set.number;

2.4 Specifying a Data Source

Typically, you define the data source with the Scheduled Data Import record. If you want to override this data source and use another data source in certain conditions, you can use the following call.

data_source = "Example LDAP Users";
Was this article helpful?
Yes, I found what I needed
No, I need more assistance