can we execute data sources(import sets) from background

Naveen Velagapu
Mega Guru

can we execute data sources(import sets) from background ? i.e. instead creating a scheduled import and execute it from background is there any package or util which will execute data source   and transform map manually?

or else does

SncTriggerSynchronizer.executeNow('scheduled import sys_id'); has capability to execute the data source without creating scheduled   import ?

18 REPLIES 18

Hi Michael,

I actually just needed to add one more line to the GlideRecord for the "sys_data_source" record for the "file_retrieval_method" field.

//create new record on 'sys_data_source' table
var impRec = new GlideRecord('sys_data_source');
impRec.initialize();
impRec.name = 'Add and transform Database Xcel';
impRec.file_retrieval_method = 'Attachment';
impRec.import_set_table_name = 'u_cmdb_ci_database';
impRec.format = 'Excel';
var targetSysID = impRec.insert();

Slava Savitsky
Giga Sage

Have a look at "DataSourceLoader" script include in your instance. I think this is what you are looking for.


MGanon
Tera Guru

None of the suggestions worked in our instance. I imported records into an import set from LDAP, queried that loaded data to get the data that I wanted, then queried the target record and updated it from the import set data. It isn't the prettiest method but it worked.

bteacher
Tera Contributor

This worked for me:

 

// Trigger a Data Source import and transform

// Get the Data Source
var dataSourceGr = current;

// Load data from the Data Source into an Import Set table
var loader = new GlideImportSetLoader();
var importSetGr = loader.getImportSetGr(dataSourceGr);
loader.loadImportSetTable(importSetGr, dataSourceGr);

// Run the Transform Maps
var transformer = new GlideImportSetTransformer();
transformer.transformAllMaps(importSetGr);