The Zurich release has arrived! Interested in new features and functionalities? Click here for more

set variable in http query parameters dynamically

shabbir9
Tera Contributor

hii 

in rest message  http query parameters if we pass name=enclave_name  ,value = asia.. they are sending enclave related filed data in response ..similarly we have enclave _name variable on catalog item (enclave names list already available on catalog item) if user selects any name in enclave _name we need to call that HTTP query parameter and show enclave related data response on the catalog item variable_(u_comment) iam using this client and script include but its not working can anyone check this 

 

client script::

var ga = new GlideAjax('GetEnclaveData');
ga.addParam('sysparm_name', 'getData');
ga.addParam('sysparm_enclave',g_form.getValue('enclave_name'));
ga.getXMLAnswer(getResponse);
function getResponse(answer) {
g_form.setValue('u_comment',answer);
g_form.setValue('enclave_administration_group',answer);

 

script include:;

var GetEnclaveData = Class.create();

GetEnclaveData.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getData:function(){
gs.log('indise SI','sh1');
var queryParam = this.getParameter('sysparm_enclave');
var restMessage = new sn_ws.RESTMessageV2('network Access', 'GET Enclave Data By Enclave Name');

restMessage.setStringParameterNoEscape('enclave_name', queryParam);
restMessage.setEndpoint(' https://connectivity-api/industrial-networks/networks/');
restMessage.setHttpMethod('GET');
restMessage.addQueryParameter('enclave_name', queryParam);
var response = restMessage.execute();
gs.log("check enclave response code"+response.getStatusCode(),'sh1');
var responseBody = response.getBody();
gs.log("check enclave response 1"+responseBody,'sh1');
var httpStatus = response.getStatusCode();
if (httpStatus == 200) {
return (responseBody);


},
type: 'GetEnclaveData'
});

6 REPLIES 6

@shabbir9 

did you create variable substitution for this in the related list?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

 

yes i have done

 

shabbir9_0-1674127020074.png