Need a script to display email id

Saib1
Tera Guru

Hi

I have the client script below it is getting displayed as sysid . 

I need email id to get displayed?

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
   g_form.setValue('user_id', newValue);
    //Type appropriate comment here, and begin script below
   }

 

 

 

Saib1_0-1700155370871.png

 

2 REPLIES 2

AshishKM
Kilo Patron
Kilo Patron

Hi @Saib1 ,

As you are trying to use "newValue" which is not reference value of changed item ( i.e. selected user ).

newValue is giving the sys_id of selected record and its adding in UserId column as it is. 

You need to use the actual field name and get the reference object and use dot walking for email.

 

Try with below code, replace the "requestor" with correct variable and same for setValue() variable.

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
  //Type appropriate comment here, and begin script below
  // alert("newValue->"+newValue); // returning sys_id of selected record without reference
var reqRef=	g_form.getReference('requestor', setUserEmail); // get the record object 
	
	//using the callback method set the UserId 
	function setUserEmail(reqRef){
		g_form.setValue("userid", reqRef.email);
	}
}

Let us know if works for you or not. 

-Thanks,

AshishKMishra

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

@AshishKM 

 

Since the variable i am using is List Collector , Hope this will not work the getReference