‎11-20-2017 05:06 AM
When submitting a request via portal, it seems portal is having a hard time executing the catalog client script.
It throws an error when it reaches this line of code
See attached. Has anyone here have seen this?
Here is the error.."TypeError: Cannot read property 'name' of undefined"
Also, if we validate a variable input if it's a number(Integer) type, when user types in characters, user isn't get prompted.
FYI. Everything works if submitting via the native UI.
Thanks,
Enrique
Solved! Go to Solution.
‎11-20-2017 07:47 AM
Can you remove variable in gereference and try again
var user1 = g_form.getReference('requested_for', doUser);
also you need to use callback function for department gliderecord
‎11-20-2017 05:12 AM
Hi Enrique,
You are using g_form.getReference() without callback which may be causing this issue.
use g_form.getReference() with callback method.
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#getReference
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
‎11-20-2017 05:25 AM
Thanks Ankur. That seems to work...i don't get the error now...but my g_form.setValue after calling the reference is not populating my field.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
try{
if (newValue == 'college'){
var user1 = g_form.getReference('variables.requested_for', doUser);
// g_form.setValue('variables.vendor_name',user.name);
// g_form.setValue('variables.vendor_tel_no',user.phone);
// g_form.setValue('variables.vendor_tel_addr',getDepName(user.department));
// if (g_form.getValue('variables.vendor_tel_addr') == 'undefined'){
// g_form.clearValue('variables.vendor_tel_addr');
// }
}else{
g_form.clearValue('variables.vendor_name');
g_form.clearValue('variables.vendor_tel_no');
g_form.clearValue('variables.vendor_tel_addr');
}
}catch(e){
alert('error: ' + e);
}
}
function doUser(user1){
g_form.setValue('variables.vendor_name',user1.name);
g_form.setValue('variables.vendor_tel_no',user1.phone);
g_form.setValue('variables.vendor_tel_addr',getDepName(user1.department));
if (g_form.getValue('variables.vendor_tel_addr') == 'undefined'){
g_form.clearValue('variables.vendor_tel_addr');
}
}
function getDepName(dep){
var gr = new GlideRecord('cmn_department');
gr.addQuery('sys_id',dep);
gr.query();
if(gr.next()){
return gr.name;
}
}
‎11-20-2017 05:39 AM
Hi Enrique,
Can you check by adding alert statements for the value?
Regards
Ankur
‎11-20-2017 06:01 AM
Thanks for your input. I really appreciate it. Alert works on desktop UI but not portal...it's weird.