Two fields with same name?

subhani6
Tera Contributor

Hi,

I have two fields with same name (company) one is reference field another is string field.Based on some conditions i need to auto populate reference field value in string field.

condition:

1. if company field(string) is empty:

what i chosen in company field(reference) that need to auto populate in company field(string).

2. if company field(string) is not empty:

what i chosen in company field(reference) that not need to auto populate in company field(string).

 

Can any one help me how can i achive this?

1 ACCEPTED SOLUTION

Try replacing

 var companyis = g_form.getValue('companyref');
    if (companyis != '') {

with

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var companyis = g_form.getValue('companyref');
var companystris=g_form.getValue('companystring');//replace companystring field correctly
if(companystris=='') //execute below only if company string is empty
{   
 if (companyis != '') {

        var compis = g_form.getReference('companyref', callback); //Replace companyref with correct field name for reference

        function callback(compis) {
            g_form.setValue('companystring', compis.name);

        }
    } 

else { //if companyis empty then clear value for companystring
        g_form.clearValue('companystring'); //Replace correct string field name for company
    }

}
}

View solution in original post

6 REPLIES 6

Narasimha9
Kilo Contributor

The solution suggested by Willem will work for you, we have implemented similar kind of requirement with the combination of BR and UI policy.

Thank you Narasimha,

Can you mark it as helpfull?👍