NOTE: See ServiceNow wiki: import sets for information on creating import set tables in the ServiceNow database.
Contents
If the user does not have administrative privileges, the following role is required before the user can insert records into import sets:
The use of import sets in Mobile Reach Apps depends on the task performed by your App.
In this situation, use the import set table created in ServiceNow in your App as you would any database table. No additional configuration is required.
In this situation, add the following attribute to the TABLE entry for the base table in the ServiceNow.xml file:
importset="<value>"
This attribute causes the Gateway to map the database table to the import set. The Gateway creates a record in the import set. Transform map(s) in the ServiceNow database then create/update the record(s) in the base table(s).
NOTE: If you are using multiple tables, you must combine the tables into a view and map that view to the import set.
You have two base tables (test_table_1 and test_table_2) in the ServiceNow database with a reference link between them. The tables are combined into a view (test_view).
An import set table (import_set_table) and two transform maps are created in the ServiceNow database. Each transform map associates fields from import_set_table to fields in one of the base tables.
The ServiceNow.xml file is used to create a link between test_view and import_set_table.
test_view displays in the Form dropdown lists in AppStudio and is used when configuring the App, just as any view would be. When a new/updated record is uploaded from the device, the Gateway uses the values configured in the ServiceNow.xml file to send values to import_set_table, which then uses the transform maps to update the correct fields in test_table_1 and test_table_2.
Map the import set to the table or view used in your App by adding attributes to the TABLE entry in the ServiceNow.xml file:
<TABLE name="test_view" importset="import_set_table"/>
If you are using transform scripts to perform the transform operation, mapping between the import set and the base tables must be explicitly configured with FIELD entries in the ServiceNow.xml file.
The following example maps fields test_assetid and test_ownedby in view test_view to fields assetid and owner in import set import_set_table. Field test_assetid is a coalesce field.
<TABLE name="test_view" importset="import_set_table">
<FIELD name="test_assetid" writename="assetid" coalesce="1"/>
<FIELD name="test_ownedby" writename="owner"/>
</TABLE>
By default, only new records or changed values in existing records are copied from import sets to the base tables. To copy all values in an existing record, instead of just the changed values, add the following attribute to the TABLE element for the import set table in the ServiceNow.xml file:
importsetcopyall="1"
Example:
<TABLE name="u_import_copy" importset="u_import_copy_set" importsetcopyall="1"/>
If your import set App changes one or more fields from having a value to being blank, you must configure your ServiceNow.xml file to copy the blank values to the base table.
The simplest and recommended method is to add the importsetcopyall="1" as described above.
If you don’t want to copy all values, perform the following to copy the null values:
new MRSupport().FixNull (source);target.<field name in base table> = MRSupport.FixNullRef (source,'<field name in import set table>');u_user is the field name in the base table and u_u1 is the field name in the import set table.
target.u_user = MRSupport.FixNullRef (source,'u_u1');
writename attribute to the FIELD that will be changed to the null value.<FIELD name='u_user' writename='u_u1'/>Attachments and signatures can be used with import set records. Configuration varies, depending on the method used to process the import sets.
attach_table: Name of the base table where the attachments will be sentattach_key: Name of the field in the import set record that contains the sys_id of the base table record that will receive the attachmentsTo get audit history records when using import sets, check the Run Business Rules checkbox in the ServiceNow database. See this ServiceNow community thread for more information.
Errors can occur at two points when uploading new or changed records to an import set:
Errors that occurs when a record is inserted into an import set are processed like errors that occur when inserting a record into a database table. The record is flagged with an error icon (
), and the text of the error is displayed on the error message tab in the RecView. The record does not insert into the table.
Errors can be generated by the transform map after the record has been inserted into the import set table. When a transform map error occurs, the record will display in the import set table, but an error message will be generated by the transform map. The text in the error message can be configured in the transform map script.
The Mobile Reach Gateway reports the transform map error as a failed insert on the client device. The record will be flagged as an error with the
icon, but the error message will show the text contained in the transform map script.