- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2016 04:45 AM
How to call script include within ui page??
I have a script include like below:
#########
var GetValue = Class.create();
GetValue.prototype = Object.extendsObject(AbstractAjaxProcessor, {
configParam : function(company,fo, param) {
var ps = gs.getProperty('default_config_param');
var gr = new GlideRecord('u_config_params');
gr.addQuery('u_company',company);
gr.addQuery('u_fo_org',fo);
gr.addQuery('u_param_name',param);
gr.query();
if (gr.next()){
return gr.u_param_value;
}
else
{
return ps;
}
},
type: 'GetValue'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2016 04:57 AM
Hi,
Following is the example to call the script include from the UI pages.
Change the names according to your convenient.
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name','helloWorld');
ga.addParam('sysparm_user_name',"Bob");
ga.getXMLWait();
alert(ga.getAnswer());
Thanks,
Veeresh
Please mark as correct, if it's helpfull
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2016 04:47 AM
The same way you would call it from Client Script, just that you need to write that code in <g:evaluate> tags.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2016 04:57 AM
Hi,
Following is the example to call the script include from the UI pages.
Change the names according to your convenient.
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name','helloWorld');
ga.addParam('sysparm_user_name',"Bob");
ga.getXMLWait();
alert(ga.getAnswer());
Thanks,
Veeresh
Please mark as correct, if it's helpfull
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2016 06:10 AM
Thanks Veeresh, it works:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 11:48 PM
Hi All,
I too have similar requirement. Here When I am calling the script include, I am getting null value. But I checked the returned value with the help of logs. It is returning correct value. Not understanding where the mistake. Please help me on this.
Script Include:
var cluster1 = Class.create();
cluster1.prototype = Object.extendsObject(AbstractAjaxProcessor,{
initialize: function() {
},
urlUser: function(){
var usr = gs.getUserID();
var terr;
var TTYPE;
var clu;
var Reg;
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',usr);
gr.query();
if(gr.next())
{
terr=gr.u_territory;
clu=gr.u_cluster;
TTYPE = gr.u_location_type;
Reg = gr.u_region;
}
gs.log("ALL CLU123******"+clu);
var url;
if(TTYPE=="Territory"){
url = "/incident_list.do?sysparm_query=opened_by.u_territory%3D"+ terr;
//gs.setRedirect(window.location);
}
else if(TTYPE=="Cluster"){
gs.log("======INSIDE SC CLU");
url = "/incident_list.do?sysparm_query=opened_by.u_cluster%3D"+ clu;
//gs.setRedirect(window.location);
//url = TTYPE+','+clu;
}
else if(TTYPE=="Region"){
url = "/incident_list.do?sysparm_query=opened_by.u_region%3D"+ Reg;
//gs.setRedirect(window.location);
}
gs.log("ALL URLi24******"+url);
var id = clu.toString();
return id;
},
Client Script in UI page :
redirect();
function redirect(){
alert("test");
var ga = new GlideAjax('cluster1');
ga.addParam('sysparm_name','urlUser');
ga.getXML(HelloWorldParse);
// ga.getXMLWait();
// alert(ga.getAnswer());
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
window.location = answer;
}
}