getReference client script HELP!

orlando_f
Kilo Contributor

Hi SN Guru's

 

Hope you can help with this request. Using the "getReference" call, I'm trying to take a users email address value (from the user referenced table) on the Change Request form and insert the email address value of a selected user straight into another field (new field) on the form using g_form.getReference method and object.

 

Thanks

 

1 ACCEPTED SOLUTION

To verify, are you wanting to copy the email of the requested_by to the description when the requested_by is changed?   Does this work for you, made a couple tweaks:



var refemail = g_form.getReference('requested_by', setDesc);



    function setDesc(refemail) {


          g_form.setValue('description', refemail.email);


    }


View solution in original post

7 REPLIES 7

orlando_f
Kilo Contributor

Thanks for the responses guys,



These answers all are good but point to a new (not existing) field from the reference table using dot walking to get there. While this is almost correct, what I'm actually trying to do is onChange of the requested_by field , is to take the email value and inserted automatically to the description field on the change request form.



I have created a script like this and its not working:



var refemail = g_form.getReference('sys_user', setDesc);



function setDesc(refemail) {


    if (requested_by)


            g_form.setValue('email', description);


  }


To verify, are you wanting to copy the email of the requested_by to the description when the requested_by is changed?   Does this work for you, made a couple tweaks:



var refemail = g_form.getReference('requested_by', setDesc);



    function setDesc(refemail) {


          g_form.setValue('description', refemail.email);


    }


In that case, you can use the below code in the script:-



var email=g_form.getReference('<your reference field>').email;//substitute the field that refers to sys_user whose email id you need.


g_form.setValue('description',email);


Thanks & Regards,


Hari