- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 12:02 PM
I am using a onChange client script to clear out values or change values in other fields on the form.
I am struggling with how to get the display value of a referenced field if possible. the her_assignment_group is a reference to the Group table.
The trouble is with the hr_assignment_group. If i use the getValue, i get the sys_id. If i use the getReference, i get Undefined. How do i get the display value? Else, what are my options to use as a condition?
------------------------------------------------------------
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
alert("Hi "+g_form.getValue('hr_assignment_group'));
if (newValue == 'KM HR') {
g_form.setValue('hr_assigned_to','');
g_form.setValue('kmhr_business_service','');
g_form.setValue('hr_ticket_type','kmhr_mgmt');}
else if (newValue == 'Time') {
g_form.setValue('hr_ticket_type','time_mgmt');
g_form.setValue('hr_assigned_to','');
g_form.setValue('kmhr_business_service','');
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 12:34 PM
You can get the name by using getReference with callBack function
Try the below script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var group = g_form.getReference('hr_assignment_group', callBack);
}
function callBack(group){
var name = group.name;
if (name == 'KM HR') {
g_form.setValue('hr_assigned_to','');
g_form.setValue('kmhr_business_service','');
g_form.setValue('hr_ticket_type','kmhr_mgmt');
}
else if (name == 'Time') {
g_form.setValue('hr_ticket_type','time_mgmt');
g_form.setValue('hr_assigned_to','');
g_form.setValue('kmhr_business_service','');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 03:27 PM
thanks. i just saw this and have moved on but i will test it. previous worked fine but I am also building an custom app so the table has literally next to no records in it so it went unnoticed but wont want it to come back and bite me. Happy Friday!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2021 05:13 AM
hi, i am trying to get value from the reference field and put it to a string field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//var b = g_form.getReference('core_company',callBack);
var b = g_form.getReference('core_company', callBack);
function callBack(b)
{
var a = b.state;
alert(a);
g_form.setValue('u_loc',a);
}
}
it is not working