- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2016 05:08 PM
I have a record producer where Department , CostCenter is added. CostCenter is dependent on Department. All these values lies in cmn_department table.
i added a Catalog Client script to pickup the values But it shows sys_id instead of values since CostCenter is Reference field. Pls help how can i get the value of Cost Center ?
Catalog Client Script
OnChange
Department
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var dept_new = g_form.getValue(newValue);
var gr = new GlideRecord('cmn_department');
gr.addQuery('name', newValue);
gr.query();
if(gr.next())
{
//var cc_value = getRefernce(gr.cost_center);
var cc_value = gr.getDisplayBox("cost_center").value;
g_form.setValue('cost_centre_new', cc_value);
g_form.setValue('gl_code_new', gr.u_gl_code);
}
//Type appropriate comment here, and begin script below
}
when i use g_form.setValue('cost_center_new', gr.cost_centre); it gives me Sys_id
Pls Help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2016 06:48 AM
Pls try below script include code is working:-
var getDepartment = Class.create();
getDepartment.prototype = Object.extendsObject(AbstractAjaxProcessor, {
deptName:function() {
var val='';
var deptId = this.getParameter('sysparm_dept');
var gr = new GlideRecord('cmn_department');
gr.addQuery('sys_id',deptId);
gr.query();
if (gr.next())
{
val=gr.getDisplayValue('cost_center');
}
return val;
}
});
-------
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2016 04:05 AM
Hi Venkat,
Please try following:
g_form.getDisplayBox('fieldname').value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2016 05:12 AM
Go to that particular table (cmn_department) from System Definitions --> Tables and make the Display Value "True" for Name column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 04:35 PM
current.tasker_history=current.getDisplayBox('tasker_status').value
Returns undefined and yes this field in table description is set to display.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2016 06:32 PM
Finally figured this out:
I have a form named "tasker" that looks up a status from a table called "status" for a variable on this table called "status".
I want to write the tasker status as it changes to a tasker history field. But because the status is a reference field all I get is the record's sys_id. So to lookup its value, you have to call the original record.
var id=current.tasker_status;
var status=new GlideRecord('x_64719_letters_status'); //x_64719 is my instance name
status.addQuery('sys_id',id);
status.query();
status.next();
current.tasker_history=current.tasker_history +" " +status.status+ gs.getUser().getDisplayName()+"<BR>";
current.update();