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

Ankur Bawiskar
Tera Patron
Tera Patron

@ramesh.r 

Can you explain the requirement on this?

Ideally you won't trigger it in this way. Probably you will have to insert record into your staging table via

GlideRecord and it would trigger the transform the record.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi

 

I have to pull the record from the LDAP server using a data source.

I have a data source and a transform map. but the issue is don't want to do this using data scheduled, so I want to directly interest record into 'sys_import_set' table with the data source and staging table name 

 

Please let me if any other way

 

Thanks

Ramesh R

Hi Ramesh,

So basically you want to trigger the LDAP pull only when you want i.e. at particular time.

How are you currently triggering that? Is it via some schedule job?

If you want to trigger the LDAP pull at particular time like once a week etc you can have schedule job and trigger the transform as well

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi,

 

Yes, currently it's pulling the record using the scheduled job, and whenever a scheduled job is running its interesting the record in the import set table (sys_import_set) then the automatically transform map is running and inserting the data,

But instead of the scheduled job directly I am trying to insert record in the import set table with all details (like data source and transform map), for that only I am using the about script.

but its not processing properly 

 

Thanks

 

Hi Ramesh,

I believe from schedule job you might be inserting record into the staging table and hence transform is triggering.

Possibly provide some more details

Please check below link for more help

https://servicenowexpert.wordpress.com/2019/01/28/auto-load-excel-spreadsheet-using-email-inbound-ac...

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader