sn_bcp_plan Report

b__DirleneS
Tera Expert

I have updated the generatePlanRelatedAssets documentation and am now able to successfully extract the following details: Asset Name, Location, Environment, Category, IP address, and Internet-facing status. However, I am still unable to extract the Operating System (OS) information. Any suggestions  on how to retrieve the OS would be appreciated. #BCP reports

Below is a small PDF sample:

b__DirleneS_0-1747242405508.png

OS function:

// Function to get operating system information for an asset
function getAssetOperatingSystem(assetType, assetName, sysId) {
try {
var os = "";

// Try to get OS from ServiceNow CI
if (sysId) {
var tableName = getTableNameForAssetType(assetType);
var gr = new GlideRecord(tableName);

if (gr.get(sysId)) {
// Check if the CI has a os field
if (gr.isValidField('os') && gr.getValue('os')) {
os = gr.getDisplayValue('os') || gr.getValue('os');
}

// Try additional alternate os fields
if (!os) {
var osFields = ['operating_system', 'os_version', 'os_name', 'u_os', 'u_operating_system'];
for (var i = 0; i < osFields.length; i++) {
var field = osFields[i];
if (gr.isValidField(field) && gr.getValue(field)) {
os = gr.getDisplayValue(field) || gr.getValue(field);
break;
}
}
}
}
}

// If no os found, extract from asset name
if (!os) {
var nameLower = assetName ? assetName.toLowerCase() : '';
if (nameLower.indexOf('linux') >= 0) {
os = 'Linux';
} else if (nameLower.indexOf('windows') >= 0) {
os = 'Windows';
} else if (nameLower.indexOf('apache') >= 0) {
os = 'Linux'; // Apache typically runs on Linux
}
}

// If still no os, infer from asset type
if (!os) {
if (assetType === 'Windows Server') {
os = 'Windows Server';
} else if (assetType === 'Linux Server') {
os = 'Linux';
} else if (assetType === 'Application') {
os = 'Windows';
} else if (assetType === 'Database') {
os = 'Linux';
} else if (assetType === 'Storage Device' || assetType === 'Storage') {
os = 'Storage OS';
} else if (assetType === 'Network') {
os = 'Network OS';
}
}

return os || 'OS Unknown';
} catch (e) {
return 'OS Unknown';
}
}

 

Thanks

NOTE: I figured it out last night 😊 

0 REPLIES 0