Catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 02:14 AM
Below the code not working
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
Var ga = new Glideajax('UserDetails');
ga.addparam('sysparm_name', check Employee);
ga.addparam('sysparm_user_sys_id',newValue);
ga.getXML(processtheresult);
function processtheresult(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == true){
g_form.setVisible('file_100',true);
}else{
g_form.setVisible('file_100',false);
}
Any idea what is the exact error above the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 02:24 AM
There are several issues with the code you provided. Here are the causes of the errors and how to fix them:
Var should be var: In JavaScript, the keyword for declaring variables is var, but your code uses Var with a capital "V". Change it to var.
Typo in addParam: ga.addparam should be ga.addParam with a capital "P".
Missing quotes around check Employee: The string check Employee should be enclosed in quotes like this: ga.addParam('sysparm_name', 'check Employee');.
Function name consistency: The function name processtheresult needs to be consistent. If it's named processTheResult in one place, it should be the same everywhere.
Comparison of answer: The answer variable might be returned as a string, so you should compare it using if(answer == 'true') or explicitly convert it to a Boolean.
(Not tested)Here is the corrected code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('UserDetails');
ga.addParam('sysparm_name', 'check Employee');
ga.addParam('sysparm_user_sys_id', newValue);
ga.getXML(processTheResult);
function processTheResult(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
g_form.setVisible('file_100', true);
} else {
g_form.setVisible('file_100', false);
}
}
}