REST Import set mode

Bhupinder1
Giga Expert

I'm working on integration and successfully loaded data in import set table via REST API call for third party product. Since SOAP/REST transforms data in synchronous mode by default so I wanted to change the mode of the import set transform. I'm using schedule script to call the REST API method and loading data in ServiceNow import tables.

 

Regards

Bhupinder

1 ACCEPTED SOLUTION

Correct missed a function. But here is full piece-


var CreateAsynchImportSet = Class.create();


CreateAsynchImportSet.prototype = {



  createImportSet: function(tableName,description) {


  var isgr = new GlideRecord("sys_import_set");


  isgr.initialize();


  isgr.mode = "asynchronous";


  isgr.state = "loading";


  isgr.table_name = tableName;


  isgr.short_description = description;


  var is_id = isgr.insert();


  return isgr;


  },



  setStateTransform: function(setId) {


  //Mark the import set as Loaded


  setId.state = "loaded";


  setId.update();


  // transform the import set


  var t = new GlideImportSetTransformer();


  t.transformAllMaps(setId);


  return setId.state;


  }


}


View solution in original post

10 REPLIES 10

Correct missed a function. But here is full piece-


var CreateAsynchImportSet = Class.create();


CreateAsynchImportSet.prototype = {



  createImportSet: function(tableName,description) {


  var isgr = new GlideRecord("sys_import_set");


  isgr.initialize();


  isgr.mode = "asynchronous";


  isgr.state = "loading";


  isgr.table_name = tableName;


  isgr.short_description = description;


  var is_id = isgr.insert();


  return isgr;


  },



  setStateTransform: function(setId) {


  //Mark the import set as Loaded


  setId.state = "loaded";


  setId.update();


  // transform the import set


  var t = new GlideImportSetTransformer();


  t.transformAllMaps(setId);


  return setId.state;


  }


}


Thanks a lot, Bhupinder! The GlideImportSetTransformer is the object that I was looking for.



I wonder why these useful objects are so poorly documented in the wiki of ServiceNow. I can only see it listed here. No member methods nor properties explanation...


Agreed. Package calls are not properly documented don't know why


Can you please mark the answer correct?


Hi Bhupinder. I clicked on "Like" for your answer and I think that is all that I can do. Since you posted the original question, you have to mark the answer that is correct. I do not think I have the permission to do it (at least, I do not see the option).