Import engine allows administrators to collect data from various data sources, and then map this data into relevant tables.
The SimpleOne import engine supports:
- different data source types.
- different file formats (if you choose "File" as the data source).
You can choose the data source, place the data from it to the temporary table (also can be called "an import set"), and after that, with the transform maps and the field maps, you can map the data from the source to the target table.
You can find a graphical procedure view of the import process in the diagram below. A more detailed description is provided further in this article.
Section |
---|
Column |
---|
| Image Added
|
|
Key conceptsKey termsConcept | Description |
---|
Import source | A record |
specifying that specifies what data an import set should import. |
Import set | A record |
containing that contains references to raw data uploaded to the staging location. |
Also, this The record also returns information about this import attempt state. |
Import set table |
A An automatically generated table that is used as |
a staging location temporary storage for imported records |
importing from a data source before transforming them. The fields in these tables are generated automatically based on before transformation. The structure of the table is automatically generated depending on the imported data. |
Transformation conversion data from an import set table to another table converting data according to the |
rules defined in a transform map and transform scripts that define the source table (the import set) and the target table. |
Transform Map |
A map specifying the relationships between a field maps, a record that specifies correlations between fields in an import set table and |
a field fields in a target table. |
Transform Script | A script that allows customizing import operations using native JavaScript extended with SimpleOne Server-Side API. |
Field Map | A record that specifies the relationship between a field in an import set table and a field in a target table. |
Coalesce | An option related to the transformation process. This option allows updating existing table records within the transformation process. For more information, navigate to the relevant article part: Coalesce. |
Anchor |
---|
| Import Sources |
---|
| Import Sources |
---|
|
Prepare raw data;Create an import source;Create a transform map;Create field sets;Run transformation.Import Sources
Creating an import source is necessary to load raw data into the system for further processing and transformation. You can set up an import source able to work with the different data source types , file format, and able to retrieve files in a different ways if this option was chosenand file formats.
- Navigate to the Import → Import -> Import Sources;.
- Click New , and fill in the form, and click Save.the fields.
If the File type is chosen, click on the attachment icon
Image Added and attach the file you need.
Tooltip |
---|
onlyIcon | true |
---|
appendIcon | info-filled |
---|
iconColor | blue |
---|
|
You can attach JSON, XML or Excel files. |
- Click Save or Save and Exit to apply changes.
Import Source form fields
Field | Mandatory | Description |
---|
Name | Y | Specify the |
Field | Description |
---|
Name | Displayed import source name. |
Import Set Table Name | Y | Specify the import set table name |
. The maximum length of the |
Displayed import set table name is 63 symbols. |
| N |
Type of external data Choose the type of import source. Available choice options: |
;JDBC;;Text retrieval methodRetrieval Method | N | Choose the method |
of adding (if relevant Type was chosen earlier). Available choice options:- Attachment;
- HTTPS;
- FTP(S):
- SFTP;
- SCP.
Format | Choose the file format (if the relevant Type was chosen earlier). Available choice options: |
After you are done with an Import Source, click Load All Records in the Related Links area, and an import set will be created.. Available choice options: This field will appear if the File type is chosen. |
Format | Y | Select the file format and attach it to the form. Available file format options: - JSON
- XML
- Excel (only when the File type is chosen)
This field will appear if the File or Text type is chosen. |
Import Text | N | Specify the text you need to import. This field appears if the Text type is chosen. Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Text format |
---|
collapse | true |
---|
| [
{
"property": "value"
},
{
"property": "value"
}
] |
|
LDAP Definition | N | Click on the magnifier icon Image Addedto choose the protocol you need. This field appears if the LDAP type is chosen.
|
After saving, the following UI actions appear on the import source form. They are responsible for further import processing.
UI Action | Description |
---|
Test load (20 records) | After clicking, a pilot import set is created with a 20-records capacity, intended for importing data structure analysis. Note |
---|
Do not use the test set for further transformation. |
|
Load all records | This UI action creates a new import set record by loading full data from the import source there. This import set can be used for further transformation. |
After loading data into the import source, saving the record and calling one of the data loading actions, a new record appears in the Import Sets related list.
You can use JSON files containing data formatted in JSON as an import source. In this case, make sure that the files follow the criteria below:
- JSON files should be valid. Use the RFC 8259 document as a guideline.
- Data types available to use in JSON structure are listed below. Dot-walking is not supported.
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | JSON Object |
---|
linenumbers | true |
---|
|
{
"top500": 1,
"name": "More",
"sector": "Oil and gas"
} |
Result: one element. The table has top500, name, sector fields and contains one record.
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Array of objects |
---|
linenumbers | true |
---|
|
[
{
"top500": 1,
"name": "More",
"sector": "Oil and gas"
},
{
"top500": 2,
"name": "Nevermore",
"sector": "Oil and gas"
}
] |
Result: an import set with the related table is created. The table has top500, name, sector fields and contains two records.
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Object with array of objects |
---|
linenumbers | true |
---|
|
// Path for Each Row == exportField
{
"exportField":[
{
"top500":1,
"name":"More",
"sector":"Oil and gas"
},
{
"top500":2,
"name":"Nevermore",
"sector":"Oil and gas"
},
{
"top500": 4,
"name": "Givememore",
"sector": "Oil and gas",
"more_info": "https://instance.example.com/company/34"
}
]
} |
Result: an import set with the related table is created. The table has top500, name, sector fields and contains three records.
When converting data for import, some changes occur to the system names of columns and tables that appear in the Import Set Table Name field of the Import Sources (sys_import) table. Namely, the names are transliterated and converted according to the following rules:
- The system changes all Cyrillic letters to the Latin ones according to their ordinal number in the list of the Latin symbols. See below how the transliteration is done:
Cyrillic symbols [
'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п',
'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я',
'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П',
'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я'
];
Latin symbols [
'a', 'b', 'v', 'g', 'd', 'e', 'io', 'zh', 'z', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'r', 's', 't', 'u', 'f', 'h', 'ts', 'ch', 'sh', 'shch', '\'', 'y', '\'', 'e', 'yu', 'ya',
'A', 'B', 'V', 'G', 'D', 'E', 'Io', 'Zh', 'Z', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'R', 'S', 'T', 'U', 'F', 'h', 'Ts', 'Ch', 'Sh', 'Shch', '\'', 'Y', '\'', 'e', 'Yu', 'Ya'
];
- All symbols that are relevant to the regular expression
/[^A-Za-z0-9_]+/u
are substituted with an underscore _ symbol. That is all symbols except capital and lowercase letters, digits, and the underscore are substituted with _ . - A system column name is split into parts by an underscore _. Then, the parts are connected with an underscore _ . For example, the name _DOC_____1 is transformed to doc_1 as a result .
The current system name of the column is transformed to lowercase.
Info |
---|
If a column name is empty, then, when converting, the system sets the following name imp_invalid_column + column number . The column number is determined by its order in the table. The numbering starts from 0. For example, imp_invalid_column0 . |
- The imp prefix is added to the name, for example,
imp_client_list
.
Import Sets
Generally, an import set should be created automatically based on the raw data uploaded into the import source. Import sets are intended to be a staging area for records imported from the data sources.
Import Set field descriptionform fields
Field | Mandatory | Description |
---|
Number | Y | Import set unique number. The field is populated automatically. |
Import Source | Y | The field contains related import source name. The field is populated automatically. |
Import Set Table | Y | The field contains the related import set table name. The field is populated automatically. Info |
---|
System names of table fields begin with imp_ prefix. |
|
State | Y | Import set loading state. |
This The field is populated automatically and is always read-only. |
Available options;Loaded;Processed;Cancelled.Import Source | Select the import source to use in this import set. |
Import Set Table | Select the import set table to use in this import set. |
Short Description | Describe your import set. |
- Navigate to the Import → Import Sets;
- Open an import set you want to transform;
- Click Transform.
- – data loading into the import set is in progress.
- Loaded – data loading into the import set has been finished.
- Processed – the import set transform has been processed.
- Cancelled – data loading has been cancelled.
|
Short Description | N | The field describes the structure of the table created and is populated with the data automatically. Field value example: Code Block |
---|
| Table structure: (top500 | name | sector) |
|
Import Set records are in the parent-child relationship with the Import Set Rows table.
Anchor |
---|
| Transform Maps |
---|
| Transform Maps |
---|
|
Transform Maps
Transform map is a set of field maps. In this set of field maps, correlations between fields of an import set table and fields of a target table are specified.
Each Every import operation requires at least one transform map which specifies the relationships relationship between the import set table and the target table.
To After creating the first import set, create a related transform map. To do this, please complete the steps below:
- Navigate to the Import → Transform Maps;
- Click New, fill in the form, and click Save.
Transform Maps field description
- Click View Transform Map on the import source form you are configuring.
- In the appeared toast message, follow the link Create Transform Map.
- Fill in the fields in the appeared form.
- Click Save or Save and Exit to apply changes.
Tip |
---|
A transform map can also be created "from scratch". To do this, complete the steps below: - Navigate to Import → Transform Maps to open the transform maps list.
- Click New and fill in the fields.
- Click Save or Save and Exit to apply changes.
|
Transform Map form fields
Field | Mandatory | Description |
---|
Name | Y |
Field | Description |
Name | Displayed transform map name. |
Active | N | Select this checkbox to make the transform map available to use. |
Source |
tableTable | Y | Select the table containing the import set data. |
Target |
tableTable | Y | Select the table where you |
want need to place imported data |
to be placed load this client-side scripts, and other additives while the transformation inserts or updates data in the target table. notification rules and other server-side engines which can be triggered by insert or update actions. In particular, workflows related to this record will not start, the field changes history will not be recorded and will not be displayed in the Activity Feed, respectively. Info |
---|
When updating records automatically with scripts, you may also need to use the Silent Load feature. In this case, use the silentMode method. |
You can find engine and business rule execution orders in the Execution order article. |
| N | Select the |
| Select this checkbox to ignore mandatory fields |
on script this the checkbox to display the Script field, where you can define the transform script. Note |
---|
If you unselect the checkbox after inserting a script, the script will not be applied within the transformation. |
|
Script | N | Insert a transform map script you want to use to transform field values from the source table to the target table. Use the runTransformRow() function with the following parameters available: - source – the Import Set Row record that will be transformed. Call a specific field from the record just like a regular SimpleRecord object. For example, source.imp_name
- map – the Transform Map record that is currently being used for the transformation process.
|
Note |
---|
Do not unselect the Use script checkbox after inserting a script, otherwise it will not be executed. |
- log – the object that contains info, warn, error methods. The methods are intended to log the transformation process.
- target – the record in the target table that will be inserted or updated within the transformation of the source record. Call a specific field from the record just like a regular SimpleRecord object. For example, target.name = source.imp_name.
- isUpdate – boolean that checks whether the target record is updated.
This script can be used to define field relationships before transformation. You can also configure relationships by creating related records via the Field Map tab of the specified transform map. If you are configuring field mapping with the script, then it is recommended to create one more allocated field map record to define the Coalesce settings for this transformation session. |
Transform script allows you to customize import operations using JS-scripts with SimpleOne Server-Side API.
Transform Script form fields
Field | Mandatory | Description |
---|
Transform Map | Y | Specify a transform map to which this script is related. |
Active | N | Select the checkbox to make the script active or inactive. |
When | Y | Specify the script type to occur: - onStart – the script runs at the start of the transformation before any Import Set Row record is read.
- onBefore – the script runs at the start of the Import Ser Row record transformation into the target table.
- onAfter – the script runs after each Import Ser Row record has been transformed into the target table.
- onComplete – the script runs when all Import Set Row records are transformed.
|
Order | N | The field specifies the order in which the transform script will be executed. Fill in this field with an integer number.
Note |
---|
The Order field is temporarily not working correctly – our team is working on its logic improvement to make it more efficient. We will inform you about the changes in one of our next releases. |
|
Script | N | Enter the script using SimpleOne Server-Side API. Use the runTransformScript() function with the following parameters available: - source – the Import Set Row record that will be transformed. Call a specific field from the record just like a regular SimpleRecord object. For example, source.imp_name.
- map – the Transform Map record that is currently being used for the transformation process.
- log – the object that contains info, warn, error methods. The methods are intended to log the transformation process.
- target – the record in the target table that will be inserted or updated within the transformation of the source record. Call a specific field from the record just like a regular SimpleRecord object. For example, target.name = source.imp_name.
When specifying the object of the target parameter, take into account the type of the field in the target table. An example of filling fields in onBefore script:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Filling fields in onBefore script |
---|
linenumbers | true |
---|
collapse | true |
---|
| (function runTransformScript(source, map, log, target /*undefined onStart*/) {
target.email = source.imp_mail; // string
target.username = source.imp_samaccountname; // string
const parsedPhoneDigits = source.imp_mobile.match(/\d/g);
target.phone = parsedPhoneDigits ? parsedPhoneDigits.join('') : null; // phone
const company = new SimpleRecord('org_company');
company.addQuery('name', 'like', source.imp_company);
company.selectAttributes('sys_id');
company.setLimit(1);
company.query();
target.company = company.next() ? company.sys_id : null; // reference
})(source, map, log, target);
|
- ignore – boolean that allows skipping the Import Set Row record.
- status_message – the message that describes the process of record transformation.
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Import skip in onBefore script |
---|
linenumbers | true |
---|
collapse | true |
---|
| (function runTransformScript(source, map, log, target /*undefined onStart*/) {
const duplicate = new SimpleRecord('task');
duplicate.addEncodedQuery(`number=${source.imp_number}^sys_id!=${target.sys_id}`);
duplicate.selectAttributes('sys_id');
duplicate.setLimit(1);
duplicate.query();
if (duplicate.next()) {
ignore = true; // skip Import Set Row
status_message = 'The "Number" [number] field should be an unique.'; // write message to Import Set Row -> Description
}
})(source, map, log, target); |
|
Field Maps
Field maps are used to define the correlation between fields of the import set table and fields of the target table. For this, you need to determine the values from the source table that Field set specifies relationships between fields in an import set table and fields in the target table determining what values from the source table will be added to the target table.
Info |
---|
During the import process, you may need to update the existing records in the target table. To set up the key relationships between the Source Table and the Target Table, create at least one field map record, with the enabled Coalesce attribute. This attribute should be enabled for a field map that contains relationships of columns with unique values. It can be an email for a user, or a serial number for a CI. In order to achieve stricter mapping, you can enable the Coalesce option for more than one Field Map record. |
To create a field map, a field set, please complete the steps below:
- Navigate to Import → Transform Maps.
- Open the transform map you want to configure.
- Click Create field map.
- The Field Mapping widget appears. See the screenshot in the table below.
- Configure field mapping within the current transformation process.
- Click Set to save changes or Cancel to discard changes.
Tip |
---|
Here is another way to create field maps: - Navigate to Import → Transform Maps
|
; a - the transform map you want to configure
|
; sys_field_map related - Field Maps related list, click New
|
, and click Save- .
- Click Save or Save and Exit to apply changes.
- Repeat the previous
|
step mapping- map that needs to be set.
|
Field set fields descriptionMap form fields
Field | Mandatory | Description |
---|
Transform |
mapMap | Y | Displays the transform map using this field |
set This The field is populated automatically. |
Source |
fieldField | Y | Select the field of the source table |
to that should be transformed |
. This field is mandatory fieldField | Y | Select the field of the target table |
where that should store the values from the source table |
should be storedWhen selected, the import set application attempts to match source values to records with values from an existing record. If a match is found, the transform map updates the record instead of creating a new record. When false, the import set application is always creating new records for each transformation. | | N | If this option is active within the transformation process, the engine checks whether values in the Target Table are equal to values in the Import Set table. If values are equal, the record in the Target Table will be updated; otherwise, a new record will be created. Tip |
---|
This option can be set up within the widget. After clicking Create Field Maps on the transform map form, a widget containing either Add coalesce or Drop coalesce buttons appears. Image Added
|
|
Use Script | N | Select the checkbox to define the transform script in |
Use source script | Select this checkbox to display |
Script | Y | Insert a script to determine a function that takes the |
source instead of the Source field.record object of the Import Set table as an argument and returns the value to put into the Target Field. Enter the script using SimpleOne Server-Side API. Use the transformEntry() function with the following parameters available: - source – the Import Set Row record that will be transformed. Call a specific field from the record just like a regular SimpleRecord object. For example, source.imp_name.
- target – the record in the target table that will be inserted or updated within the transformation of the source record. Call a specific field from the record just like a regular SimpleRecord object. For example, target.name = source.imp_name.
The field appears when the Use Script checkbox is selected. Note |
---|
Do not unselect the Use |
|
source scriptScript checkbox after inserting a script; otherwise, |
|
otherwise executed.
- Navigate to Import → Import Sets.
- Open an import set you want to transform. Make sure that the state is Loaded.
- Click Transform.
As a result, the toast message Import is completed
appears. Imported data will be transferred into the target table.
The scheme below shows the sequence of events triggered by the transformation:
Image Added
- The sequence begins with the onStarttransform script. It will be executed at the start of the transformation before any source row is read.
- The field map script takes the record object of the Import Set Row table as an argument and returns the value to put into the Target Field.
- The transform map script transforms field values from the source row to the target row.
- The onBefore transform script is executed before the source row is transformed into the target row.
- Between the execution of onBefore and onAfter scripts, the target record is inserted or updated.
- The onAfter transform script runs when the source row has been transformed into the target row.
- The onComplete transform script is executed when all source rows are transformed.
Info |
---|
The onBefore and onAfter scripts are repeatable, they will run until each record is transformed. |
Info |
---|
When creating a field sets, create the first linkage for the sys_id fields of the source and the target tables using the Coalesce option. It will tie the tables with each other for further importing. After that, create other pairs for all the fields you want to transform. |