Passing parameters to script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 04:05 AM
Hi,
I am calling the script include, but GlideAjax cannot be called from REST.
This script include is used mostly from from client side but i need to call from Server but don't want to have to edit the script include.
var ga = new GlideAjax("AllCatIntegrationWS");
ga.addParam("sysparm_name", "ADSearch");
ga.addParam("sysparm_searchQuery", securityGrp);
ga.addParam("sysparm_parameter1", {and:[ //Query to search using ANR {"ANR":{"EQ":securityGrp}}, {"objectcategory":{"EQ":"group"}}, {"objectclass":{"EQ":"group"}}, {"extensionAttribute15":{"NOTEQ":"NoAutomation"}}, {"groupType:1.2.840.113556.1.4.803:":{"EQ":"2147483648"}}, {"AllAccountType":{"NOTEQ":"S1"}}, {"AllAccountType":{"NOTEQ":"S2"}}, {"AllAccountType":{"NOTEQ":"S3"}} ]});
ga.getXML(SecurityGrpSearch);
function SecurityGrpSearch()
{
var results = run;//response.responseXML.documentElement.getAttribute("answer");
gs.log(results.toString()); return {"success": results.toString()};
}
So i was going to go down the route of:
var scInc = new AllCatIntegrationWS();
But my variables are not defined on the script include as you can see in red below.
I need to populate the two values below in blue.
Can i do what the two orange lines above are doing not using glideAjax.
I am sure this doesn't make sense, any questions let me know.
Thanks,
ADSearch: function () {
var response;
var jsonOutput;
var SOAP_MESSAGE = this.getEnvironment();
// Script gives a warning about using JSON like this
var json = new JSON();
//Get search parameters for AWARE query
var searchQuery = this.getParameter('sysparm_searchQuery');
var parameter1 = this.getParameter('sysparm_parameter1');
var parameter2 = this.getParameter('sysparm_parameter2');
var parameter3 = this.getParameter('sysparm_parameter3');
var parameter4 = this.getParameter('sysparm_parameter4');
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 05:43 AM
Hi Shay,
If you are using the getParameter() methods to get your variables, that indicates it's accepting in put from a GlideAjax call on the client side. The same script include cannot be used for client and server side operations.
What you can do is... break the core logic out in to a server side script include, then wrap the client side around that so it calls the server logic. Now your server logic can be used by server side business rules, workflow scripts, email notification scripts, etc. directly.
Your client callable script include accepts parameters from the client scripts, then calls the server side script include's logic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2017 10:31 PM
I believe you can provide both for client and server in a single function if you really want to.
doSomething: function(paramA, paramB) {
var valueA = (paramA) ? paramA : this.getParameter('sysparm_a');
var valueB = (paramB) ? paramB : this.getParameter('sysparm_b');
var result;
if(this.getParameter('sysparm_a')) result = this.newItem("result");
...
if(result) {
result.setAttribute("response", 'yay');
}
else {
return something;
}
}
Not that you should, I would still recommend separate functions, but it is at least possible from my understanding.