For a client we build a button in a service request which supposed to integrate with a soap request. The client didn’t want the Soap Call to be happening on the change of a field but wanted the user to choose it actively trough a button.
A button on a catalog item.. There is no such thing on the wiki. A button that enables a Soap request, that combination will probably never be on there. Here is how to do it:
Enabling a soap request trough a script include is easy, just use the example script that is provided by the soap request (using the ‘Preview script usage’ related link).
A button can be created by using a ui_macro, the ui_macro can then be used as a variable in the catalog item.
This is how to create the ui_macro (simplified version):
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<button name="not_important" value="sysverb_solution"
onClick="return GetIncidents(this);">${gs.getMessage('Using Soap request to retrieve data.')}
</button>
<script>
function GetIncidents(x) {
var User = g_form.getValue("requested_for");
var gajax = new GlideAjax('exampleSoap');
gajax.addParam("sysparm_User", grUser.user_name)
gajax.getXML(ajaxResponseSearch);
function ajaxResponseSearch(response){
var returnStr = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('return_xml', returnStr+'');
}
return true;
}
</script>
</j:jelly>
The response of the soap request in this case will be placed in the ‘return_xml’ variable on the same request item.
Easy and useful, at least I hope.
Enjoy and if you have any questions you can reach me at [at]
.