Reputation: 2379
I tried to integrate external soap based api using servicenow client side scipt options. My intention is to initiate an external api call when an incident is created. But i am getting uncaught reference error sn_ws is not defined exception.
function onSubmit() {
try {
var s = new sn_ws.SOAPMessageV2('global.IQTrack', 'VerifyApiKey');
s.setStringParameterNoEscape('VerifyApiKey.apiKey', 'dfghdhgdjh');
var response = s.execute();
var responseBody = response.getBody();
var status = response.getStatusCode();
}
catch(ex) {
alert(ex);
}
}
Is this the way to initiate api call? If it is so why it is getting sn_ws is not defined.
Upvotes: 1
Views: 1647
Reputation: 363
I hope,sn_ws is a server-side API.
I think GlideAjax
method will help you to get rid of this issues.
please go through below links,I think it will help you to sort out this issues.
http://wiki.servicenow.com/index.php?title=GlideAjax#gsc.tab=0
And alternative is use client-side webservices API like XMLHttpRequest
Upvotes: 0
Reputation: 601
That's because sn_ws is a server-side API.
You need to either use GlideAjax, or a client-side webservices API such as XMLHttpRequest. You can find an excellent article on GlideAjax, here: http://snprotips.com/blog/2016/2/6/gliderecord-client-side-vs-server-side
If your aim is to initiate the message once a ticket is created, then you should definitely be doing this server-side, not in a client script.
Upvotes: 1