- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 05:23 AM
Hi Experts.
I've launch my Client Script in production, but suddenly it something went wrong.
UI Type: All
Isolate script: True
onChange script:
Script returns response and alert() also working, but g_form.setDisplay() only does not work.
*It works in Platform UI
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('GetChoiceValueInCSM');
ga.addParam('sysparm_name', 'getChoiceByDependentValue');
ga.addParam('sysparm_element', 'u_third_category');
ga.addParam('sysparm_dependentvalue', g_form.getValue('subcategory'));
ga.addParam('sysparm_tablename', 'sn_customerservice_case');
ga.getXMLAnswer(getChoices);
function getChoices(response) {
if (response) {
g_form.setDisplay('u_third_category', true);
alert("!!");
} else {
g_form.setDisplay('u_third_category', false);
alert("!!22");
}
}
}
I can't even guess the cause. How can I fix it?
Regards.
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 08:29 PM
Dear Respondents
The cause of this issue has been identified.
The problem wasn't the script. The cause was that the Workspace View Rule did not show the field.
Thank you for your cooperation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 05:56 AM
Try to use setValue rather than setDisplay
g_form.setValue('u_third_category', true);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 06:01 AM
Hi,
Thanks for your reply. but it doesn't work also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 06:10 AM
Hi, You missed one line of Glideajax code, add below line
function getChoices(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");// This line
if(answer){
g_form.Value('u_third_category', 'true');
}
else{
g_form.Value('u_third_category','false');
}
}
Please let us know if it helpful or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 06:47 PM
Hi
The code you mentioned is complemented with getXMLAnswer()
And alert() works fine so the GlideAjax code doesn't seem to be a problem.
var answer = response.responseXML.documentElement.getAttribute("answer");// This line
Please refer to the following