auto populate values (single line text) based on another field value (type reference)

santiago_bergal
Tera Expert

Hello, I have a variable (type reference) which is called territory. Based on the selection of a given territory, another field (CISO group) should be autopopulated. I was working on the client script below but it hasn't worked so far. Any clues? suggestions?


function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var territory = g_form.getReference('territory', callback); 

 

function callback(territory) { //reference is passed into callback as first arguments


g_form.setValue('ciso_group',territory.sys_user_group);


}

1 ACCEPTED SOLUTION

g_form.setValue('ciso_group',territory.u_ciso_group); 

Did this not work? What type of variable is  ciso_group? is it a reference variable or single line test?

also try to do  alert(territory.u_ciso_group); in your function to check what are you getting.


Raghav
MVP 2023

View solution in original post

8 REPLIES 8

RaghavSh
Kilo Patron

Tour code seems correct. can you confirm below:

var territory = g_form.getReference('territory', callback);   // which table does your territory field refers to?

 

function callback(territory) { //reference is passed into callback as first arguments


g_form.setValue('ciso_group',territory.sys_user_group);   // is sys_user_group a field on the table to which territory refers to?


Raghav
MVP 2023

RaghavSh, thanks for your quick reply.

 

territory is a reference type variable and it refers to the [core_company] table.
I don't know if sys_user_group is a field on the table to which territory refers to. I'll check. Thanks!

yes you can only dot walk the fields on core_company table like territory.name , will give you company's name selected in territory.


Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023

Just checked. I tried with the name of the field (u_ciso_group) and with reference (sys_user_group) as a second attempt. Neither worked.

santiago_bergal_0-1670503073978.png