Notifications

325 views

Description

When a web service import set having multiple associated transform maps is run in ASYNC mode via the schedule script execution 'Asynchronous Import Set Transformer', only one transform map is executed.

Steps to Reproduce

  1. Create an import set table 'u_web_service_import'.
  2. Create two transform maps for this import set table with different orders.
  3. Create a before insert business rule on 'sys_import_set' table having:

    Filter:
    Import set table is 'u_web_service_import'
    Action:
    Mode to Asynchronous

    4. Navigate to the Scheduled Script Execution 'Asynchronous Import Set Transformer'.
    URL: /nav_to.do?uri=sysauto_script.do?sys_id=d1bc736c0a0a0b2b002c3442345d6824

    5. Modify the script as follows:
    Change line #8

    From:
    igr.addQuery("state", "loaded");

    To:
    igr.addQuery("state", "loading");

    This is required, otherwise the import will never be transformed.

    6. Send data from REST API explorer or Postman to the Import set API for this import set table.
    7. Go to the scheduled script execution from step 4 and click on Execute Now.
    8. Open the recently created import and observe that there is only 1 import set run and 1 import set row. Only one of the two transform maps runs.

Workaround

When GlideImportSetTransformerWorker is initialized, the list of all transform map sys_ids need to be passed. For this, you need to update the functions sTransform() and getMap() with the script below. 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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();
}

 


Related Problem: PRB1330544

Seen In

There is no data to report.

Fixed In

New York

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2019-05-21 11:42:41
Published:2019-04-04