Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to insert the record in Import Sets table using script

ramesh_r
Mega Sage

Hi All,

I want to get record using import set and I want to do it using a script,

so I have used the below script and its interesting the record but its not processing and pulling the data.

Please guide me where i need to change the script.

Inserting record in 'sys_import_set' table

var imp =  new GlideRecord('sys_import_set');
imp.initialize();
imp.state = 'loaded';
imp.data_source  = '0e2d4f4cdba690d06d438a3a489619e2';
imp.table_name = 'u_get_external_user';
imp.insert();

Records get inserted but is not processing

 

find_real_file.png

 

Thanks

Ramesh R

16 REPLIES 16

Suseela Peddise
Kilo Sage

Hi,

You can try  dataSourceImportUtils() to schedule a loaded import.

For ex:
/* Schedule Loaded import*/
var res=new global.dataSourceImportUtils().scheduleImport(dataSourceID, transformMapIDs);
var schRec=new GlideRecord("sys_trigger");
schRec.get('sys_id',res);

//gs.log('Transform map result next '+res +' '+schRec.getValue('next_action'));
workflow.info('Import schedule ('+res+') has been scheduled at '+schRec.getDisplayValue('next_action'));

 

Hope this helps!

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.

Hi Suseela ,

I have exicuted your script from backgroub script but i am getting this error

 

find_real_file.png

 

Thanks

Ramehs R

Sudhanshu Talw1
Tera Guru

Hi,

I have a doubt,Why you are not creating a data source & uploading the excel sheet?

You also have option to run transform script.

 

Thanks

Sudhanshu

Hi 

 

I am not updating excel sheet, i am pulling the record from LDAP using existing data source

 

Thanks

Ramesh R