- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2017 02:10 AM
Need sample scripts on how to call a WSDL Function from a Business Rule
Can someone help please?
Thanks KD
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2017 05:07 PM
have a read:
SOAPMessageV2 Uses code in business rule...
Problem statement in above location:
I'm trying to use SOAPMessageV2 API, for that I have created one table with 3 columns (First Name, Last Name & Number) in my test environment. Since all the tables in Service Now can be published by Direct Web Services.
I've created an outbound web services and use direct Web Services WSDL in this out bound web services, Now I want that on my custom table when I'll enter number and submit first name and last name will return.
Can anyone please help me to write a code for this via Business Rule and SOAPMessageV2 API.
Write an onSubmit client script something like this:
function onSubmit() {
var firstn = '';
var lastn = '';
var nbr = ''; //<Assign this field to what was entered>
var requid = "<WebServiceName>"
var script = "getName('" + firstn + "','" + lastn + "','" + nbr + "','" + requid + "')";
var answer = AJAXEvaluateSynchronously(script);
g_form.setValue('u_result', answer);var myExp = /<CODE>/
var code;code = answer.search(/RAN Successfully/i);
if (code != '1'){ //This is looking in the returned result to confirm it ran successfully.
var id = answer.search(/<ID>/i);
logonid = answer.substr(id+4, 6);
}g_form.setValue('u_username',logonid);
}
This is the Preview Script that will display for the Soap Message
try {
var s = new sn_ws.SOAPMessageV2('<Soap Message Name>', '<Soap Message Function>');//override authentication profile
//authentication type ='basic'
//r.setAuthentication(authentication type,profile name);s.setStringParameterNoEscape('first_name', 'TestReqq');
s.setStringParameterNoEscape('last_name', 'TestReqqLast');
s.setStringParameterNoEscape('nbr', '4785');
s.setStringParameterNoEscape('requesting_id', '<WebServiceName>');
var response = s.execute();
var responseBody = response.getBody();
var status = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
And this is the Business Rule that is called from the client script:
function getName(firstn, lastn, nbr, requid) {
var s = new SOAPMessage('<Soap Message Name>', '<Soap Message Function>');
s.setParameter('first_name', firstn);
s.setParameter('last_name', lastn);
s.setParameter('num', nbr);
s.setParameter('requesting_id', requid);
var response = s.post();
return response;
}
I have not tested anything, and this might not even work, but this is just to give you an overview of how developers customise.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2017 05:07 PM
have a read:
SOAPMessageV2 Uses code in business rule...
Problem statement in above location:
I'm trying to use SOAPMessageV2 API, for that I have created one table with 3 columns (First Name, Last Name & Number) in my test environment. Since all the tables in Service Now can be published by Direct Web Services.
I've created an outbound web services and use direct Web Services WSDL in this out bound web services, Now I want that on my custom table when I'll enter number and submit first name and last name will return.
Can anyone please help me to write a code for this via Business Rule and SOAPMessageV2 API.
Write an onSubmit client script something like this:
function onSubmit() {
var firstn = '';
var lastn = '';
var nbr = ''; //<Assign this field to what was entered>
var requid = "<WebServiceName>"
var script = "getName('" + firstn + "','" + lastn + "','" + nbr + "','" + requid + "')";
var answer = AJAXEvaluateSynchronously(script);
g_form.setValue('u_result', answer);var myExp = /<CODE>/
var code;code = answer.search(/RAN Successfully/i);
if (code != '1'){ //This is looking in the returned result to confirm it ran successfully.
var id = answer.search(/<ID>/i);
logonid = answer.substr(id+4, 6);
}g_form.setValue('u_username',logonid);
}
This is the Preview Script that will display for the Soap Message
try {
var s = new sn_ws.SOAPMessageV2('<Soap Message Name>', '<Soap Message Function>');//override authentication profile
//authentication type ='basic'
//r.setAuthentication(authentication type,profile name);s.setStringParameterNoEscape('first_name', 'TestReqq');
s.setStringParameterNoEscape('last_name', 'TestReqqLast');
s.setStringParameterNoEscape('nbr', '4785');
s.setStringParameterNoEscape('requesting_id', '<WebServiceName>');
var response = s.execute();
var responseBody = response.getBody();
var status = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
And this is the Business Rule that is called from the client script:
function getName(firstn, lastn, nbr, requid) {
var s = new SOAPMessage('<Soap Message Name>', '<Soap Message Function>');
s.setParameter('first_name', firstn);
s.setParameter('last_name', lastn);
s.setParameter('num', nbr);
s.setParameter('requesting_id', requid);
var response = s.post();
return response;
}
I have not tested anything, and this might not even work, but this is just to give you an overview of how developers customise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2017 05:11 PM
Thanks Vab. Appreciate the help.
KD