Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Making import sets created for Import Set API calls "Asynchronous" to prevent Synchronous transform, for specific imports - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Making import sets created for Import Set API calls "Asynchronous" to prevent Synchronous transform, for specific imports
KB0781666

Making import sets created for Import Set API calls "Asynchronous" to prevent Synchronous transform, for specific imports


7994 Views Last updated : Sep 14, 2022 public Copy Permalink English (Original)
  • English (Original)
  • Japanese
KB Summary by Now Assist

Issue

All import sets created for Import SET API calls are "Synchronous". What this means is that as an import set row is created, it is transformed immediately.

To prevent immediate transform the import set can be made "Asynchronous". 

REST Import Set API method insertMultiple was added in Quebec

https://docs.servicenow.com/bundle/quebec-paris-df3/page/release-notes/rn-combined/quebec-paris/quebec-paris-importandexport-release-notes.html

Resolution

Import Set API method insertMultiple

In Quebec a new method insertMultiple was added to the Import Set API. This method allows you to import multiple records and then transform them asynchronously:

https://developer.servicenow.com/dev.do#!/reference/api/sandiego/rest/c_ImportSetAPI#import-POST-insertMultiple

Custom Business Rule (Not Supported)

This can be achieved as follows:

  1. Create a "Before" insert business rule on the sys_import_set table with a conditional check on the Import set table (table_name) that should not be transformed synchronously.
  2. Under actions, add 'Mode' to 'Asynchronous'.
  3. Create a Scheduled job that runs every few minutes and transforms the 'asynchronous' import set, with the following script and set it to run 'Periodically'.

There is an OOB Scheduled Script Execution "Asynchronous Import Set Transformer", you can use that as a guideline and change line 8 (igr.addQuery("state", "loaded")) and replace it with the following 2 lines: 

igr.addQuery("table_name", "the staging table name");
igr.addQuery("state", "loading");

 

The complete Script:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
transformAsyncIset();

function transformAsyncIset() {
    var igr = new GlideRecord("sys_import_set");
    igr.addQuery("mode", "asynchronous");
    igr.addQuery("table_name", "STAGING_TABLE_NAME");
    igr.addQuery("state", "loading");
    igr.query();
    while (igr.next()) {
        sTransform(igr);
    }
}

function sTransform(igr) {
    var mapsList = getMap(igr.table_name);

    var t = new GlideImportSetTransformerWorker(igr.sys_id, mapsList);
    t.setProgressName("Transforming: " + igr.number);
    t.setBackground(true);
    t.start();
}

function getMap(sTable) {
    var mapGR = new GlideRecord("sys_transform_map");
    mapGR.addQuery("source_table", sTable);
    mapGR.addActiveQuery();
    mapGR.query();

    var mapsList = [];
    while (mapGR.next())
        mapsList.push(mapGR.getUniqueValue());

    return mapsList.join();
}

 


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.