Display content in Multiline text

shruthi17
Kilo Explorer

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);

}

}

}

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

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.

 

View solution in original post

14 REPLIES 14

Brad Bowman
Kilo Patron
Kilo Patron

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.

 

Hello Brad,

Yes, I am getting output with alert of fsDetail.

"complete-partial" is a variable that contain 2 dropdown options:

1)Partilal

2)Complete

 

So when i select "Partial" the fsDetail value must get populated in "File_System_detail" which is a Multiline text field.

 

g_form.setValue('File_System_detail', fsDetail);

 

Can you please suggest me on this.

 

Thanks,

Shruthi

OK.  Sounds like this is only not working then due to how you are referencing complete-partial, so use one of the 2 lines I suggested, ensuring that the variable name and the select box choice Value match exactly (characters and case-sensitive). 

Hello Brad,

I modified as below . But the  fsDetail value is not getting populated in "File_System_detail" which is a Multiline text field. I have done the value match exactly.

 

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);

 


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);

}

}

}