- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 06:18 AM
Hi,
i have two fields the first is a reference on a table , i should once the user select the name in the field Application (1) the second field Refernence cde (2) will be filled automatically by assignment group concerning the name
this the table :
once user select in the field application "name" the filed reference cde should be fill with the assignment group of this name("test");
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 06:29 AM
On the form you can do it like below
Add an oncchange client script that runs on change of Application field
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ref = g_form.getReference('<application field name>', getAppl);
}
function getAppl(ref) {
g_form.setValue('<Reference code field name>', ref.<name of field on referenced table>);
}
}
If you want to do it on the list then you have to create a Business Rule.
Condition: <reference code field > is empty
AND
Application changes
Before
Update
Script:
current.<reference code field> = current.<application field>.<reference code field>;
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 09:18 AM
hi
when i try this background script i got empty in the script :
var gr= new GlideRecord('u_applications_bte');
gr.get('2064c0b937fabe00449c138943990e74'); //this the id of teh groupe that i must get in the field refernce cde once i select the name of the app in teh field application
gs.print(gr.u_assignement_group_b.getDisplayValue());
but i noticed one thing and i try it and i can get the name of the groupe i go to the table u_application_bte and i select one record and the i copy the sys_id of the record and i put it in background script and it works i got the name of the group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 09:40 AM
yea so you need to get this script right, now you know what sys id its expecting.
Work your way up to identify the gap. Script is fine, it is the value you are passing is not right it seems.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 02:36 AM
Try below.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ref = g_form.getReference('u_application_bte', getAppl);
function getAppl(ref) {
g_form.setValue('u_groupe_d_affectation_bte', ref.<assignmengroup_field_name>);//replace assignmentgroupfield name accodingly from referenced table
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 02:57 AM
hi
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ref = g_form.getReference('u_application_bte', getAppl);
}
function getAppl(ref) {
g_form.setValue('u_groupe_d_affectation_bte', ref.u_assignement_group_b);
}
the name of the field Application is u_application_bte
the name of the field Refernce Cde is u_groupe_d_affectation_bte
the name of the assignment group in the table is u_assignment_group_b
but i still getting the sys_id of the group i should get the name

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 03:01 AM
That is expected.
As Reference field always return sys_id
Option 1: So, you either need to chagne the field on the form to Reference instead of String
OR
Option 2: Use Script include & Client script to get the name of the group.