The Now Platform® Washington DC release is live. Watch now!
‎03-18-2019 10:26 AM
Requesting Access (User/E": TypeError: Unable to get property 'email' of undefined or null reference
here is the code (working fine on platform but not on portal), i am not sure how to use GlideAJAX. Appreciate your help
var userID = g_user.userID;
var isPM = g_user.hasRole('pm');
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(isPM){
g_form.setValue('u_user_s_email_address', g_form.getReference('u_user_name').email);
g_form.setValue('u_hire_submission_date', g_form.getReference('u_user_name').u_hire_submission);
g_form.setValue('u_user_s_telephone', g_form.getReference('u_user_name').phone);
} }
Solved! Go to Solution.
‎03-18-2019 11:00 AM
In order to use g_form.getReference() in portal you must use a callback function like so:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var userID = g_user.userID;
var isPM = g_user.hasRole('pm');
if(isPM){
g_form.getReference('u_user_name',function(user){
g_form.setValue('u_user_s_email_address', user.email.toString());
g_form.setValue('u_hire_submission_date', user.u_hire_submission.toString());
g_form.setValue('u_user_s_telephone', user.phone.toString());
});
}
}
You can also utilize GlideAjax to call a script include then return the user values as needed.
Please see the below link for reference on what client scripts and APIs work in Service Portal:
‎03-18-2019 10:33 AM
g_form.getReference() DOES NOT work in service portal.
You will have to use glide Ajax.
Regards,
Sachin
‎03-18-2019 10:46 AM
can you share glide Ajax code (i am new to glide Ajax)
‎03-18-2019 11:07 AM
Please find below code for glide ajax for your requirement
https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f96196e
Regards,
Sachin
‎03-18-2019 11:00 AM
In order to use g_form.getReference() in portal you must use a callback function like so:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var userID = g_user.userID;
var isPM = g_user.hasRole('pm');
if(isPM){
g_form.getReference('u_user_name',function(user){
g_form.setValue('u_user_s_email_address', user.email.toString());
g_form.setValue('u_hire_submission_date', user.u_hire_submission.toString());
g_form.setValue('u_user_s_telephone', user.phone.toString());
});
}
}
You can also utilize GlideAjax to call a script include then return the user values as needed.
Please see the below link for reference on what client scripts and APIs work in Service Portal: