CI Principal Class always return False
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
I need to fetch the CI Principal Class which is enabled for other tables/classes. i tried to use the below, in this it always return False for all classes. var classNameToCheck = 'cmdb_ci_lb_netscaler'; //cmdb_ci_lp_firewall cmdb_ci_computer var gr = new GlideRecord('cmdb_class_info'); gr.addQuery('name', classNameToCheck); gr.query(); if (gr.next()) { var principal_class= gr.getValue('principal_class'); if (gr.principal_class) { gs.info(classNameToCheck + ' is a principal class.'); } else { gs.info(classNameToCheck + ' is NOoooT a principal class.'); } } O/p : cmdb_ci_computer is NOoooT a principal class. But it is a part of Principal class only Can any one lell what is the problem, what i missed here
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hi,
When sharing code it's helpful to use the "insert code sample" option </> to make it readable.
If you're wanting to do this by querying the Class Info table, the following will work
var isPrincipalClassGR = new GlideRecord('cmdb_class_info')
if(isPrincipalClassGR.get('class' , 'cmdb_ci_server')){
gs.info("is principal class " + JSUtil.getBooleanValue(isPrincipalClassGR , 'principal_class'));
}
JSUtil is a useful script include to get boolean values