- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2020 01:53 PM
I need to display some content in Multiline text only when I select particular variable . Currently I have written a Script include and Cliet script for the same. In form level after i select specific variable the Multiline text field is getting displayed but the content in the text is not getting displayed. Below is my Client script please suggest me what ca be done to resolve the issue.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var server_sys_id = g_form.getValue('ServerCI');
var ga = new GlideAjax('fmr_add_backup_FS');
ga.addParam('sysparm_name', 'validateRequestDetails');
ga.addParam('sysparm_tvm', server_sys_id);
ga.getXML(getResponse);
function getResponse(response) {
var fsDetail = response.responseXML.documentElement.getAttribute('answer');
alert(fsDetail);
if (complete-partial == 'Partial'){
g_form.setValue('File_System_detail', fsDetail);
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2020 06:11 AM
Are you getting the results that you expect with your alert of fsDetail? If not, make sure the script include has the Client callable box checked, and post it here for review. Whether you are getting the correct answer back from the server script or not, this line is not correct, so the variable value will never get set since the if statement can never evaluate to true
if (complete-partial == 'Partial'){
What is complete-partial? That is not defined anywhere. If it is a variable, change this line to
if (g_form.getValue('complete-partial') == 'Partial'){
unless this onChange script is running on this variable, then you can just use
if (newValue == 'Partial'){
in either case provided 'Partial' (case-sensitive) is the Value of a select box choice list, or whatever type this is.
If complete-partial is something that is coming back from the server, different syntax is needed to make that work, but I'd need to see the script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2020 10:02 AM
Have you tried commenting out the if line (and closing bracket) to see if the value gets set? you can also add an alert inside the if block. If your alert(fsDetail) is showing you what you expect, then there has to be an error in the if line or the setValue, and the above steps will help narrow that down. Are you certain there are no extraneous spaces before or after the 2 variable names and/or in the select box choice list Value? If you post screen shots showing those three I can put another set of eyes on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2020 11:53 AM
Another thing to try - shouldn't need it, but I've seen stranger things - change the setValue line to
g_form.setValue('File_System_detail', fsDetail.toString());
Also, what is the text in fsDetail? If it's something long with special characters, maybe that's throwing it off. Once you've done the other troubleshooting steps I've mentioned, try temporarily setting
fsDetail = 'this should be working';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2020 01:15 PM
Hello Bran,
I tried manually declaring fsDetail . I tried to set value to variable"File_System_detail" outside and inside the 'IF' condition.
But still no luck.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert('test Mount_info');
var server_sys_id = g_form.getValue('ServerCI');
alert('hello');
var ga = new GlideAjax('fmr_add_backup_FS');
ga.addParam('sysparm_name', 'validateRequestDetails');
ga.addParam('sysparm_tvm', server_sys_id);
ga.getXML(getResponse);
fsDetail = 'this should be working';
g_form.setValue('File_System_detail', fsDetail.toString());
// function getResponse(response) {
// var fsDetail = response.responseXML.documentElement.getAttribute('answer');
// alert(fsDetail);
if (g_form.getValue('complete-partial') == 'Partial'){
g_form.setValue('File_System_detail', fsDetail.toString());
}
}
//}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2020 02:29 PM
Please post a screenshot of the File_System_detail variable Question tab. Another thing to check - do you have any other client scripts, catalog client scripts or catalog UI policies that affect this variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2020 07:42 PM