- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 10:22 AM
I am attempting to test a script include that will be used in a Transform rule in the Integrationhub ETL. The script looks up a computer CI using the passed in serial number.
I have tried a few variations of both the background script and script include, but it seems as if the script include isn't being called correctly. It returns 'script: undefined' from the gs.print. The gs.log actions in the script include are not showing up in the system logs.
Not sure what I'm doing wrong, so any help would be appreciated.
Background script:
var serialNumber = '123456';
var ci_discoverySource = new global.CIUtils().getComputerBySerialNumber(serialNumber);
gs.print(ci_discoverySource);
Script Include:
Name: CIUtils
Application: Global
Accessible from: All application scopes
var CIUtils = Class.create();
CIUtils.prototype = {
initialize: function() {
},
getComputerBySerialNumber: function(serialNumber) {
gs.log(serialNumber);
var computerGR = new GlideRecord('cmdb_ci_computer');
computerGR.addQuery('serial_number', serialNumber);
computerGR.query();
if (computerGR.next()) {
gs.log(computerGR.discovery_source);
return computerGR.discovery_source; // Return the discovery source if found
} else {
return null; // Return null if not found
}
},
type: 'CIUtils'
};
If I run the function directly in the background script it correctly returns the discovery source.
Working Background script:
var serialNumber = '123456';
getComputerBySerialNumber(serialNumber);
function getComputerBySerialNumber(serialNumber) {
gs.log(serialNumber);
var computerGR = new GlideRecord('cmdb_ci_computer');
computerGR.addQuery('serial_number', serialNumber);
computerGR.query();
if (computerGR.next()) {
gs.log(computerGR.discovery_source);
return computerGR.discovery_source; // Return the discovery source if found
} else {
return null; // Return null if not found
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 11:25 PM
Hi @Brent Caudill
The issue lies with your script include name. There is already an OOB script include with the same name, CIUtils. Please change your script include name, and it should work.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 11:25 PM
Hi @Brent Caudill
The issue lies with your script include name. There is already an OOB script include with the same name, CIUtils. Please change your script include name, and it should work.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 04:19 AM
Doh! Thank you @J Siva ! Can't believe I didn't catch that, but thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 04:31 AM
@Brent Caudill Glad it helped 👍