I am trying to get email address from user table using client script on my custom form. I created a reference field from the user but when I try to get the value I get the sys_id.

Wirasat
Tera Guru

I am trying to get email address from user table using client script on my custom form. I created a reference field from the user but   when I try to get the value I get the sys_id.

12 REPLIES 12

Prateek kumar
Mega Sage

Can you share your script here



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Wirasat
Tera Guru

Here is the client script I am trying to use.



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


    var refcc= g_form.getValue('cc');


        g_form.setValue('email', refcc);


}


Can you try this:



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


    var refcc= g_form.getDisplayBox('cc').value;


        g_form.setValue('email', refcc);



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

reference field will always return the sys_id.   you need to use getDisplayValue() function in your code. refcc variable is basically getting the sysid and you are trying to set that value into email field which is a string field.


replace var refcc= g_form.getDisplayValue('cc'); and it should work