How to retrieve values from table into a multi text field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 08:02 AM - edited 04-26-2024 08:18 AM
HI All ,
I have a requirement to get all the values from a table which has an common IP address and print it in a multiline text on catalog item for that I created a client script onchange and a script include the scripts as below :
getAllUpdatedVirtuals: function() {
var arr_3 = [];
var deprovision = this.getParameter('sysparm_address');
var virtuals = new GlideRecord('u_network_f5_vips');
virtuals.addEncodedQuery('u_f5_ip=' + deprovision);
virtuals.query();
while (virtuals.next()) {
var update = virtuals.u_name.getDisplayValue().toString() + ',' + virtuals.u_destination.getDisplayValue().toString();
arr_3.push(update + '\n');
}
return arr_3.toString();
},
client script :
var ga = new GlideAjax('F5_destination');
ga.addParam('sysparm_name', 'getAllUpdatedVirtuals');
ga.addParam('sysparm_address', newValue);
ga.getXMLAnswer(getResponse);
function getResponse(response) {
alert('test' + newValue);
var answer = response;
alert('ans' + answer);
g_form.setValue('all_updated_virtuals', answer.split("\n"));
In alert ans it returning null .Kindly suggest where is it going wrong .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2024 11:20 PM
Hello,
Please make below changes in the client script and try again.
Old:
ga.getXMLAnswer(getResponse);
New:
ga.getXML(getResponse);
Old:
var answer = response;
New:
var answer = response.responseXML.documentElement.getAttribute('answer')
Also create logs in script include to check if you are getting correct values in the array or not.
If my answer helps you in any way please mark it as correct or helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 07:19 AM - edited 04-29-2024 07:19 AM
HI Vishwa ,
Thanks for the response .
I have tried the script include script in background script its working fine.
But in client side it is still showing as null after changes u suggested .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 09:09 AM
I had read about this approach to use when sending multiple values from server side to client side. It basically says to encode the data as json object while sending from server side and then retrieve in the client side.I haven't implemented it but i'll give you an overview and you can try from your end.
on server side ----
var obj = {};
obj.n1 = (the value that you need to send);
obj.n2 = (the value that you need to send);
var json = new JSON();
var d = json.encode(obj);
return d;
------------------------------------
on client side -----
in the call back function :
answer = answer.evalJSON();
You can try this and let me know if you are facing any issues...I'll try it then...