- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2014 01:09 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2015 07:28 AM
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2014 10:25 AM
Finally got it worked by creating script include and calling from business rule or script. Below is the code-
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;
},
type: 'CreateAsynchImportSet'
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2015 11:05 AM
This is very interesting. I also have data coming from a REST get method and synchronous transformation is giving me performance problems. I have tried out your solution and I am able to do the import of the data into the corresponding import table. However, once the loading of data is finished, I do not know how to trigger the transform to the target table from the script.
How do you do it? I have tried to change manually the state of the import set, but this did not work:
isgr.state = "loaded";
isgr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2015 02:28 PM
Here you go-
var imp = new CreateAsynchImportSet();
var isId = imp.createImportSet("table name","Import Set Description");
// Logic for calling REST methods and loading data
imp.setStateTransform(isId);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2015 01:34 AM
Thanks Bhupinder, but you forgot to give us the implementation of the method "setStateTransform". It is not not in the code of the class "CreateAsynchImportSet" that you published... Maybe you did not copy the full implementation of the class in your post. Can you please share?