ETL Definition quick start guide
Learn how to set up and use an ETL definition to import data into ServiceNow tables.
Before you begin
Role required: admin
For this quick start guide, we're going to import data in the following JSON file to ServiceNow target tables. This JSON file contains hierarchical data for a school, classes, students and subjects. Save the following content to a JSON file.
[{
"name": "schoolA",
"classes": [
{
"name": "classA",
"students": [
{"name": "studentA", "subjects": [{"name": "subjectA", "marks": 80},
{"name": "subjectB", "marks": 90},{"name": "subjectC", "marks": 100}]},
{"name": "studentB", "subjects": [{"name": "subjectA", "marks": 75},
{"name": "subjectB", "marks": 85}, {"name": "subjectC", "marks": 95}]}
]
},{
"name": "classB",
"students": [
{"name": "studentC", "subjects": [{"name": "subjectA", "marks": 60},
{"name": "subjectB", "marks": 70}, {"name": "subjectC", "marks": 80}]},
{"name": "studentD", "subjects": [{"name": "subjectA", "marks": 55},
{"name": "subjectB", "marks": 65}, {"name": "subjectC", "marks": 75}]}
]
}
]
}]
Procedure
Create a data source and load data.
Create a data source with a Format of JSON, and the Path for each row as
//.Check the Data in single column option.
Save the data source.
Attach the above JSON file to the data source.
Select Load All Records to load records to the import set table.
JSON Data Source form for the School Import.
6. Open the import set row created.
The record should be saved to a single JSON column.
The import set row with the record saved as a single JSON column.
Create the target table structure to import data.
In this example, we have a school with multiple classes, each class has multiple students, and each student has multiple subjects.
Create a table structure to reflect these relationships.
School -> name : string.Class -> name : string , school : reference to school.Student -> name : string, class : reference to class.Subject -> name : string, mark : integer, student : reference to student.
Create an ETL Definition to map the JSON record data to target tables.
Go to System Import Sets > ETL Definition.
Select New.
Enter a name and save the record.
Record of ETL definition named school definition.
Create entities.
Under the ETL Entities tab, select New.
Set the Name as
Import Setand save.Add import set entity fields for all the leaf values of the JSON.
The field/path is the path from the root of the JSON and we mark arrays with [*].
The Import Set ETL Entity form.
4. Go to ETL Definition and under ETL Entities, select **New**.
5. Set the **Name** as `School`.
6. Set the **Table** as the school table created in step 2.
7. Set the **Path** as `school`.
8. Save the Entity.
9. Select **Generate fields** under Related Links.
This should generate the **Name** field. Set the **Coalesce** to **true**.
ETL Entity for School.
10. Go to ETL Definition and under ETL Entities, select **New**.
11. Set the **Table** as the class table created in step 2.
12. Set the **Path** as `class[*]`.
Using \[\*\] makes it an entity with multiple rows.
13. Select **Generate fields** under Related Links.
14. Since **School** in the ETL Entity fields is a reference field, modify the **Field/Path** to `school.name` and set **Coalesce** to **true** for the **Name** field because name is unique.
ETL Entity for Class.
15. Add Entities to Student and Subject as well.
For Subject, set **Coalesce** to **true** for both the **Name** and **Student** fields.
ETL Entity for Student.
ETL Entity for Subject.
Add RTE Entity Mappings.
Go to RTE Entity Mappings and select New.
Set the Name to
Import Set to school.Set the Source Entity to Import Set.
Set the Target Entity to School.
Keep the Order as 100.
Under RTE Field Mappings, select New.
For the Source Field, select School name.
You can only select the Entity fields from the source entity.
For the Target Field, select Name.
You can only select the Entity fields from the target entity.
RTE Entity Mapping for Import set to school.
9. Go to ETL Definition and under RTE Entity Mappings select **New**.
10. Set the **Name** to `Import set to class`.
11. Select **Source Entity** to **Import Set**.
12. Select **Target Entity** to **Class**.
13. Set **Order** to **200**.
14. Add the RTE Field Mappings to map **Name** and **School name**.
The school **Target Field** should map to the **School name** of the import set. The system does the school look up using this value and sets the correct school reference.
RTE Entity Mapping for Import set to class.
15. Add mappings for Student and Subject as well.
RTE Entity Mapping for Import set to student.
RTE Entity Mapping for Import set to subject.
Create a Robust Import Set Transformer record and run the import.
Go to the Data source created in step 1.
Select the Robust Transformer tab and select New.
Set a Name.
Set the Transformer definition to the ETL Definition we created earlier.
Set Verbose.
Selecting Verbose is not required, but enables you to debug the configuration. Switch this off before moving to production because it can negatively impact the performance.
Robust Import Set Transformer for School Transformer.
6. Select **Submit**.
Data Source for School Import.
7. Select **Load All Records**.
8. Select **Run Robust Transform**.
9. Select **Transform**.
10. Go to the import set.
11. Select the Import Set Rows tab and open the import set row record.
12. If the configuration works correctly, it should show the import set row record with all the records inserted.
School import.