Any one please- I need to copy the field value to other field on portal side

mastan babu ko1
Tera Contributor

I have created the catalog item, So in that there is field ( X ) Ref from user table which i have filter with only to get Functional accounts(bots)

 

So when I have selected email in X field at portal side then field looks as unvisiable, But there is a record. So in order remove confusion for End users.

 

I have created another field X1  behind to X field, So it should  copy the email to this X1 field 

 

But I was not able to do in client script ANY ONE PLEASE HELP!

1 REPLY 1

ZoranVasic
Tera Contributor

You can just use one field if you don't need any additional information. Here is the documentation piece on this. Just search for setValue fn. It accepts the third argument which is the display value for the variable. 

 

function onChange(control, oldValue, newValue, isLoading) {
   if ( newValue == '') {
      return;
   }
    g_form.getReference("X", callback);
    
    function callback(user_record){
        g_form.setValue("X", user_record.sys_id, user_record.name);
    }   
}

 

 
If you really need two variables for this then you would the onChange script would look something like this:

 

function onChange(control, oldValue, newValue, isLoading) {
   if ( newValue == '') {
      return;
   }
    g_form.getReference("X", callback);
    
    function callback(user_record){
        g_form.setValue("X1",  user_record.name);
    }   
}

 

 

You could even combine the two values and not have your variable field blank for users. It's a bad experience to have a blank field that actually has values selected. 
Based on this, with IF statements, you could present some other field value when you select a bot. 


Best, 
Zoran Vasic