list databases related with all the mapped application services for the selected business applicatio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 02:56 AM
How to list databases related with all the mapped application services for the selected business applications with script include using reference qualifier in a catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 10:32 PM
Step 1:
var GetDatabasesForBusinessApp = Class.create();
GetDatabasesForBusinessApp.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDatabases: function() {
var businessAppId = this.getParameter('sysparm_business_app');
var dbIds = [];
// Find all Application Services related to the Business App
var relGR = new GlideRecord('cmdb_rel_ci');
relGR.addQuery('parent', businessAppId); // assuming parent is Business App
relGR.addQuery('type.name', 'Depends on::Used by');
relGR.query();
var serviceIds = [];
while (relGR.next()) {
serviceIds.push(relGR.child.sys_id.toString());
}
if (serviceIds.length > 0) {
// Find all related Databases from those services
var relDB = new GlideRecord('cmdb_rel_ci');
relDB.addQuery('parent', 'IN', serviceIds);
relDB.addQuery('type.name', 'Depends on::Used by');
relDB.addQuery('child.sys_class_name', 'cmdb_ci_database');
relDB.query();
while (relDB.next()) {
dbIds.push(relDB.child.sys_id.toString());
}
}
return dbIds.join(',');
}
});
Note: make sure script include is client callable
step 2:
Reference Qualifier:
javascript: 'sys_idIN' + new GetDatabasesForBusinessApp().getDatabases(current.variables.business_application);
✔️ If this solves your issue, please mark it as Correct.
✔️ If you found it helpful, please mark it as Helpful.
—
Shubham Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2025 01:06 PM
It is not working still, how to proceed further. It is showing as 'no matches found '