How can I get the 'Friendly name' of a ci class in a Service Catalog item variable?

kent_harwell
Giga Contributor

This client script will return the name of the table (eg 'cmdb_ci_appl'), but what I want is the display name of 'Application...

Function is on change 'u_ci'

var u_ci_class is the variable I want to populate with the label of the 'cmdb_ci_appl' table

function onChange(control, oldValue, newValue, isLoading) {

  if (isLoading || newValue == '') {

  return;

  }

  userObject = g_form.getReference('u_ci'); //this is a reference field which performs a lookup on cmdb_ci

  var u_class = userObject.sys_class_name;

  g_form.setValue('u_ci_class', u_class);

}

if u_ci is a configuration item in the Application Class then

u_class = 'cmdb_ci_appl'

What I want is for u_class = 'Application'

I can find no documentation to help with this.

2 REPLIES 2

Gurpreet07
Mega Sage

I tried with various of the functions from client side and its seems like nothing is working. Better to use glideAjax to call a server side script include and use function   getClassDisplayValue()   in there.


Charlotte Pakes
Tera Guru

Hi Kent,



You may have already resolved this, but I had a similar requirement today.



I used GlideAjax as Gurpreet suggested. I did a GlideRecord query on sys_db_object to get the label, something like:



var tblname = this.getParameter('sysparm_tblname');
var tbl = new GlideRecord('sys_db_object');
tbl.get('name',tblname);
return tbl.label;


Hope that is helpful. If anyone has a better solution, please reply.



Cheers,



Charlotte