
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 11:12 AM
Can someone help me understand what line is causing this issue:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var state = g_form.getValue('state');
if (state == '3') //closed complete {
var parent = g_form.getUniqueValue();
var ga = new GlideAjax('GetParentResults'); //script include
ga.addParam('sysparm_name', 'GetResults'); //function
ga.addParam('sysparm_sys', parent); //pass the value
ga.getXML(updateResults);
} {
function updateResults(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert(answer);
if (answer === '') {
g_form.setValue('overall_status', '');
} else {
var textToFind = 'Fail';
if (answer.indexOf(textToFind) == -1) { // true if text does not contain textToFind
g_form.setValue('overall_status', 'Pass');
} else
g_form.setValue('overall_status', 'Fail');
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 01:59 AM
@cms1 ,
There exist an unwanted bracket as shown in screenshot, Please check the all the opening and closing brackets in the code and try again!
Please mark my answer helpful, if it works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 01:40 AM - edited 02-01-2023 01:41 AM
Hi @cms1 ,
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var state = g_form.getValue('state');
if (state == '3') { // closed complete
var parent = g_form.getUniqueValue();
var ga = new GlideAjax('GetParentResults'); //script include
ga.addParam('sysparm_name', 'GetResults'); //function
ga.addParam('sysparm_sys', parent); //pass the value
ga.getXML(updateResults);
}
}
function updateResults(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert(answer);
if (answer === '') {
g_form.setValue('overall_status', '');
} else {
var textToFind = 'Fail';
if (answer.indexOf(textToFind) == -1) { // true if text does not contain textToFind
g_form.setValue('overall_status', 'Pass');
} else {
g_form.setValue('overall_status', 'Fail');
}
}
}
In the Line
if (state == '3') //closed complete { should be -- > if (state == '3') { // closed complete
and check the state value you are comparing it is a string, try to compare without quotes.
Regards,
Shravan.
Please mark as the correct answer if this helped you
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2023 01:59 AM
@cms1 ,
There exist an unwanted bracket as shown in screenshot, Please check the all the opening and closing brackets in the code and try again!
Please mark my answer helpful, if it works for you.