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

i believe the custom reference field u have created is referenced to user table, as a result it bascially give u the username of that user. create a custom field with userid.email using dot walking.based on the value user u will select it will give u email id.


chidanandadhath
Kilo Guru

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


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


          return;


    }


    var user= g_form.getReference('userid');


        g_form.setValue('email', user.email_id);


Wirasat
Tera Guru

Saw someone response on the community.   here is the script.



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


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


          return;


    }


    var obj= g_form.getReference('cc', getEmail);


}


function getEmail(obj) {


  if (obj != '')


        g_form.setValue('email', obj.email);


}