how to fill a field automatically depending on a reference field

Fdeveloper
Kilo Guru

Hi,

find_real_file.png

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 :

find_real_file.png

once user select in the field application "name" the filed reference cde should be fill with the assignment group of this name("test");

1 ACCEPTED SOLUTION

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

 

-Anurag

View solution in original post

21 REPLIES 21

hi @Jaspal Singh ,

i can't change the first field to string it must be a reference to do the second opton how can i acheive that what should i put in the script include

Since, you are finding things difficult try below.

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

  var ref = g_form.getReferenceAdvancedPortal('u_application_bte', u_assignement_group_b.name); //name is field that stores name of group. If it is cutom replace name with u_name
    

        g_form.setValue('u_groupe_d_affectation_bte', ref.u_assignement_group_b_name);//name is field that stores name of group. If it is cutom replace name with u_name
    
    }

//Also ensure assignment field has correct spelling that you created as in script I see assignment being used. Ensure it is correct as per your created field name

 

Refer link.