- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2025 08:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2025 01:19 AM
Is issue still open @munukuntlak
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2025 09:04 AM - edited ‎11-07-2025 10:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2025 10:31 AM - edited ‎11-11-2025 10:34 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || isTemplate) {
return;
}
var instanceName = g_form.getValue('instance_name');
// Validate instance is selected
if (!instanceName) {
g_form.addErrorMessage('Please select an Instance Name first');
g_form.setValue('select_all_databases', 'false');
return;
}
if (newValue === true) {
// SELECT ALL CHECKBOX IS CHECKED
console.log('Select All Databases: Initiating...');
// Hide the List Collector and clear its value
g_form.setVisible('database_instance', false);
g_form.setMandatory('database_instance', false);
g_form.setValue('database_instance', '');
// Call backend Script Include to get all databases
var ga = new GlideAjax('global.DB_Provisioning_UTIL');
ga.addParam('sysparm_name', 'getAllDatabasesWithNames');
ga.addParam('instance_name', instanceName);
ga.getXMLAnswer(function(response) {
if (response) {
try {
var result = JSON.parse(response);
console.log('Response received: ' + JSON.stringify(result));
if (result.sysIds && result.sysIds.length > 0) {
// Store comma-separated sys_ids in hidden field
g_form.setValue('all_database_sysids', result.sysIds.join(','));
// Display database names in multi-line text field
g_form.setValue('selected_databases', result.names.join('\n'));
g_form.setVisible('selected_databases', true);
// Show success message
g_form.addInfoMessage(result.sysIds.length + ' database(s) selected');
} else {
// No databases found
g_form.addInfoMessage('No databases found for this instance');
g_form.setValue('select_all_databases', 'false');
g_form.setVisible('database_instance', true);
g_form.setMandatory('database_instance', true);
}
} catch (e) {
// JSON parsing error
console.error('Error parsing response: ' + e.message);
g_form.addErrorMessage('Error loading databases: ' + e.message);
g_form.setValue('select_all_databases', 'false');
g_form.setVisible('database_instance', true);
g_form.setMandatory('database_instance', true);
}
} else {
// No response from server
console.error('No response from server');
g_form.addErrorMessage('Unable to retrieve databases. Please try again.');
g_form.setValue('select_all_databases', 'false');
g_form.setVisible('database_instance', true);
g_form.setMandatory('database_instance', true);
}
});
} else {
// SELECT ALL CHECKBOX IS UNCHECKED
console.log('Select All Databases: Clearing selections...');
// Show the List Collector again
g_form.setVisible('database_instance', true);
g_form.setMandatory('database_instance', true);
// Hide and clear the selected databases display
g_form.setValue('all_database_sysids', '');
g_form.setValue('selected_databases', '');
g_form.setVisible('selected_databases', false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2025 11:20 AM
Back ground Script
// Get 10 Business Applications and their related MSSQL Databases
var grApp = new GlideRecord('cmdb_ci_business_app');
grApp.setLimit(10);
grApp.query();
gs.info('========================================');
gs.info('BUSINESS APPLICATIONS AND THEIR DATABASES');
gs.info('========================================');
var totalApps = 0;
var totalDatabases = 0;
while (grApp.next()) {
totalApps++;
var appName = grApp.getValue('name');
var appSysId = grApp.getUniqueValue();
gs.info('');
gs.info('App #' + totalApps + ': ' + appName);
gs.info(' Sys ID: ' + appSysId);
// Find related databases
var dbList = [];
var grRel = new GlideRecord('cmdb_rel_ci');
// Check where business app is parent
grRel.addQuery('parent', appSysId);
grRel.addQuery('child.sys_class_name', 'cmdb_ci_db_mssql_database');
grRel.query();
while (grRel.next()) {
var dbSysId = grRel.getValue('child');
var dbName = grRel.child.getDisplayValue();
dbList.push({
sys_id: dbSysId,
name: dbName
});
}
// Check where business app is child
grRel = new GlideRecord('cmdb_rel_ci');
grRel.addQuery('child', appSysId);
grRel.addQuery('parent.sys_class_name', 'cmdb_ci_db_mssql_database');
grRel.query();
while (grRel.next()) {
var dbSysId = grRel.getValue('parent');
var dbName = grRel.parent.getDisplayValue();
dbList.push({
sys_id: dbSysId,
name: dbName
});
}
// Display databases
if (dbList.length > 0) {
gs.info(' Databases (' + dbList.length + '):');
for (var i = 0; i < dbList.length; i++) {
gs.info(' - ' + dbList[i].name + ' [' + dbList[i].sys_id + ']');
totalDatabases++;
}
} else {
gs.info(' Databases: NONE FOUND');
}
}
gs.info('');
gs.info('========================================');
gs.info('SUMMARY');
gs.info('========================================');
gs.info('Total Business Apps: ' + totalApps);
gs.info('Total Databases Found: ' + totalDatabases);
gs.info('========================================');
***********************************************************************************************************************************
getDatabases: function(businessAppId) {
if (!businessAppId) {
return '';
}
var dbList = [];
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent', businessAppId);
gr.addQuery('child.sys_class_name', 'cmdb_ci_db_mssql_database');
gr.query();
while (gr.next()) {
dbList.push(gr.getValue('child'));
}
return dbList.join(',');
},
************************************************************
.getDatabases(current.variables.application_name);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2025 06:12 PM - edited ‎11-17-2025 06:43 PM
getDatabases: function(businessAppId, environment) {
if (!businessAppId) {
return '';
}
var dbSysIds = [];
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('parent', businessAppId);
gr.addQuery('child.sys_class_name', 'cmdb_ci_db_mssql_database');
gr.query();
while (gr.next()) {
dbSysIds.push(gr.getValue('child'));
}
if (dbSysIds.length == 0) {
return '';
}
var filteredDbList = [];
var grDB = new GlideRecord('cmdb_ci_db_mssql_database');
grDB.addQuery('sys_id', 'IN', dbSysIds.join(','));
if (environment) {
grDB.addQuery('environment', environment);
}
grDB.query();
while (grDB.next()) {
filteredDbList.push(grDB.getUniqueValue());
}
return filteredDbList.join(',');
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2025 11:09 PM - edited ‎11-19-2025 05:14 AM
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">
<!-- Get current user -->
<g:evaluate>
var current_user = gs.getUserID();
</g:evaluate>
<!-- Query business applications assigned to current user -->
<g:evaluate jelly="true">
var gr_apps = new GlideRecord('cmdb_ci_business_app');
gr_apps.addQuery('owned_by', gs.getUserID());
gr_apps.orderByDesc('sys_updated_on');
gr_apps.query();
var app_count = 0;
var gr_count = new GlideRecord('cmdb_ci_business_app');
gr_count.addQuery('owned_by', gs.getUserID());
gr_count.query();
while (gr_count.next()) { app_count++; }
</g:evaluate>
<!-- HEADER -->
<div style="background:white; padding:20px; border-radius:10px; box-shadow:0 2px 6px rgba(0,0,0,0.12);">
<h2 style="margin-bottom:5px; color:#2c3e50;">📱 My Business Applications</h2>
<p style="color:#6c757d; margin-bottom:20px;">
Showing business applications owned by <b>${gs.getUserDisplayName()}</b>
</p>
<!-- If applications exist -->
<j:if test="${app_count > 0}">
<table style="width:100%; border-collapse:collapse; font-size:14px;">
<thead>
<tr style="background:#f8f9fa; border-bottom:2px solid #dee2e6;">
<th style="padding:10px; text-align:left;">Application Name</th>
<th style="padding:10px; text-align:left;">Version</th>
<th style="padding:10px; text-align:left;">Business Criticality</th>
<th style="padding:10px; text-align:left;">Environment</th>
<th style="padding:10px; text-align:left;">Status</th>
</tr>
</thead>
<tbody>
<!-- Loop through business applications -->
<j:while test="${gr_apps.next()}">
<tr style="border-bottom:1px solid #eee; cursor:pointer;"
onmouseover="this.style.backgroundColor='#f1f3f5'"
onmouseout="this.style.backgroundColor='white'"
onclick="window.open('/${gr_apps.getTableName()}.do?sys_id=${gr_apps.sys_id}', '_blank');">
<td style="padding:10px; color:#007bff; font-weight:500;">
${gr_apps.name}
</td>
<td style="padding:10px;">
${gr_apps.version}
</td>
<td style="padding:10px;">
<j:choose>
<j:when test="${gr_apps.business_criticality == '1_critical'}">
<span style="background:#dc3545; color:white; padding:4px 8px; border-radius:4px; font-size:12px;">
${gr_apps.getDisplayValue('business_criticality')}
</span>
</j:when>
<j:when test="${gr_apps.business_criticality == '2_high'}">
<span style="background:#fd7e14; color:white; padding:4px 8px; border-radius:4px; font-size:12px;">
${gr_apps.getDisplayValue('business_criticality')}
</span>
</j:when>
<j:when test="${gr_apps.business_criticality == '3_medium'}">
<span style="background:#ffc107; color:#000; padding:4px 8px; border-radius:4px; font-size:12px;">
${gr_apps.getDisplayValue('business_criticality')}
</span>
</j:when>
<j:otherwise>
<span style="background:#6c757d; color:white; padding:4px 8px; border-radius:4px; font-size:12px;">
${gr_apps.getDisplayValue('business_criticality')}
</span>
</j:otherwise>
</j:choose>
</td>
<td style="padding:10px;">
${gr_apps.environment}
</td>
<td style="padding:10px;">
<span style="background:#e7f1ff; color:#004085; padding:4px 8px; border-radius:4px; font-size:12px;">
${gr_apps.getDisplayValue('install_status')}
</span>
</td>
</tr>
</j:while>
</tbody>
</table>
</j:if>
<!-- If NO applications -->
<j:if test="${app_count == 0}">
<div style="padding:40px; text-align:center; background:#f8f9fa; border-radius:10px; border:2px dashed #dee2e6;">
<div style="font-size:48px;">📱</div>
<p style="font-size:18px; margin-top:10px; color:#495057;">
No Business Applications Owned
</p>
<p style="color:#6c757d;">
You currently don't own any business applications.
</p>
</div>
</j:if>
</div>
</j:jelly>
