Call Script Include in my onComplete transform script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 11:32 PM - edited 07-16-2024 11:46 PM
Hi, I would like to seek help from the expert about my requirement. I have created a script include and I wanted to use this in my transform script. However, it is not copying to the second table.
I also wanted to delete the record generated from the script include in my transform script.
Expected result
1. Copy and map record from script include in the transform map
2. Delete the record copied from.
onComplete transform script
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var fromTable = new siUtil().fnRecord(source.instance_key);
var toTable = new GlideRecord('u_tbl2_sam_sw_install');
toTable.query();
while (toTable.next()) {
toTable.initialize();
toTable.display_name = fromTable.display_name;
toTable.discovery_model = fromTable.discovery_model;
toTable.discovery_source = fromTable.discovery_source;
toTable.publisher = fromTable.publisher;
toTable.version = fromTable.version;
toTable.installed_on = fromTable.installed_on;
toTable.instance_key = fromTable.instance_key;
toTable.insert();
}
rec.deleteRecord(); //-->>> DELETE THIS SOURCE RECORD AFTER INSERT
})(source, map, log, target);
Script Include
var siUtil = Class.create();
siUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fnRecord: function() {
var resultList = [];
var tbl1= new GlideRecord('u_customed_table1');
tbl1.addQuery('operational_status', "2");
tbl1.query();
while (tbl1.next()) {
var tbl1SerialNumber = tbl1.getValue('serial_number');
var swInstallGR = new GlideRecord("cmdb_sam_sw_install");
swInstallGR.addEncodedQuery("instance_keyCONTAINS" + tbl1SerialNumber );
swInstallGR.query();
while (swInstallGR.next()) {
resultList.push(tbl1SerialNumber.sys_id.toString());
}
}
return resultList.toString();
},
type: 'siUtil
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 11:54 PM - edited 07-16-2024 11:57 PM
Hi @olufsen ,
I think you have created client callable script include, which is not required here. you need a server callable script include here to be called in onComplete transform script.
Resolution:
Disable the client callable checkbox from script include.
Add some log messages to check if the script include is getting triggered for sure.
If your logic is correct then it should resolve your issue.
Thanks.
Hope this helps.
If my response turns useful, please mark it helpful and accept solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 05:23 AM
Thank you @HrishabhKumar I have updated. I am not confident though if my onComplete declaration and gliderecord is correct. Anything you find wrong is appreciated.