- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2023 04:52 AM
hii
in script include "GetEnclaveData" iam getting the rest message response in responsebody(
(var responseBody = response.getBody();) i need fetch that responsebody and show it on u_comment variable can anyone correct this script where i am doing wrong in below client script i need to fetch script include responsebody onto this client script ..
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('GetEnclaveData');
ga.addParam('sysparm_name','getData');
ga.getXMLAnswer(getResponse);
alert('hello');
function getResponse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert('answer');
var reqbody = JSON.stringify(answer);
alert('reqbody');
g_form.setValue('u_comment',reqbody);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2023 10:49 PM - edited ‎01-10-2023 10:49 PM
@shabbir9 Please add the return statement in your script include method named getData() to get the response body when you make Ajax call from client script.
var GetEnclaveData = Class.create();
GetEnclaveData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getData: function() {
var restMessage = new sn_ws.RESTMessageV2('`network Access', 'GET network Data By network Name');
//restMessage.setEndpoint(' https://connectivity-api.netbuz-l.cotp/industrial-networks/networks/');
restMessage.setHttpMethod('GET');
var queryParam = gs.getVariable('query_param');
restMessage.addQueryParameter('parameter_name', queryParam);
var response = restMessage.execute();
var responseBody = response.getBody();
gs.log("check enclave response" + responseBody);
var httpStatus = response.getStatusCode();
if (httpStatus == 200) {
// Store the response body in a variable
gs.setVariable('response', responseBody);
return JSON.stringify(responseBody);
// gs.log("check enclave response"+responseBody);
}
},
type: 'GetEnclaveData'
});
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2023 05:17 AM
GlideAjax with getXMLAnswer() method will only return the exact answer you need.
Comment line : var answer = response.responseXML.documentElement.getAttribute("answer");
function getResponse(answer){
alert('answer '+answer);
var reqbody = JSON.stringify(answer);
alert('reqbody ' +reqbody);
g_form.setValue('u_comment',reqbody);
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2023 05:39 AM
its working fine but in u_comment iam getting "null"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2023 09:15 PM
Could you please confirm whether you are getting the alert popup with correct value.
What type of field u_comment?
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2023 09:31 PM
iam getting alert pop up null ...and in u_comment also null..u_comment is multi line text variable on catalog item