The CreatorCon Call for Content is officially open! Get started here.

How do I exclude an import set from being deleted when Scheduled Cleanup is activated?

bdoug
Kilo Expert

I am making a REST call and populating an Import Set table with the information retrieved.   I have to hard code the Import Set sys id into the script to ensure that the data retrieved is added to the Import Set.   The problem I have is that when the Scheduled Cleanup Import Set Deleter job runs it deletes my Import Set how can I exclude it?

var r = new sn_ws.RESTMessageV2('SL_DEVICE_API2', 'get');

var response = r.execute();

var jsonString = response.getBody();  

var parser = new JSONParser();  

var parsed = parser.parse(jsonString);

var rec = new GlideRecord('u_import_em7_records');  

for(var key in parsed.result_set) {

      var value = parsed.result_set[key];

  rec.initialize();  

  rec.u_name = value.name;  

  rec.u_ip = value.ip;  

  rec.u_organization = value.organization;    

  rec.u_class_type = value.class_type;

  rec.u_did = key.replace("/api/device/","");

  rec.sys_import_set = '68212c6013771600220fb86f3244b0a7';

  rec.insert();  

1 ACCEPTED SOLUTION

Just to give an update on this I found the fix for this I do not know how I overlooked it before.   I did not need to hard code the sys_id of the Import Set since whenever the scheduled job would run it would create a new Import Set.   It would set the mode to Synchronous which would cause the transform to run right away.


View solution in original post

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Bobby,



In that case you have to customize script include - ImportSetCleaner to exclude the import set you want.


FYI - this is an OOB script include so modifications carry with it the standard disclaimer "Once you modify it, you own it."


I guess I have to open a ticket with Hi support to see what my options are then.


Just to give an update on this I found the fix for this I do not know how I overlooked it before.   I did not need to hard code the sys_id of the Import Set since whenever the scheduled job would run it would create a new Import Set.   It would set the mode to Synchronous which would cause the transform to run right away.