Creating discovery source via scripts from application scope

Aditya Prasad
Tera Contributor

Hello Team, 

I am creating an graph connector application for importing devices into CMDB. I see we need to create discovery source for cmdb_ci table for this, and its in global scope. 

Is there a way to create this discovery-source in global scope and bundle this into the app or any scripts to create this inside the app ?

6 REPLIES 6

Hi,

Here is a nice blog on how it should could be done...
https://www.servicenow.com/community/developer-blog/how-to-capture-demo-data-in-scoped-application/b...

 

Work perfectly for the Location example. Sadly, not so much for Choice (sys_choice) table. The "Create Application file" is not available for records in that table. 

 

Sorry, I'm out of ideas. 

Regards,
Niklas

Constantine Kr1
Giga Guru

A lot of the CMDB ServiceGraph connectors use the following code template inside a Fix Script to automatically populate the Discovery Source field in the CMDB. The Fix Script will automatically run on installation of the application in a new instance.

 

var source_name = "YOUR_APP_NAME";
var dsUtil = new global.CMDBDataSourceUtil();
dsUtil.addDataSource(source_name);
var util = new sn_itom_license.ITOMLicensingUtils();
util.addDiscoverySource(source_name);

 

 

Information on fix scripts:

From Fix Script Documentation: Fix scripts run at the first installation or updated after they have been added to an application. However, previous fix scripts do not run on subsequent application updates, and you must manually run any necessary fix scripts.