- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2014 11:38 AM
I'm making a ui page and attempting to include jquery, as well as responsive slides (a plugin for jquery). To do so I created two 'script includes' that contained the contents of jquery as well as the responsive slides plugin. I just want to include these scripts, but to be honest I have no idea how to. I attempted to read the wiki about them Script Includes - ServiceNow Wiki but to be honest it just left me clueless. Does anyone have any ideas?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2014 02:49 PM
<script> should work. I've used it many times.
Or you could use either of the two jelly versions:
UI Scripts use:
<g:include_script src="rslides.jsdbx" />
or for UI Macros use:
<g:rslides />
or if that doesn't work:
<g:macro_invoke macro="rslides" />
Also, it would be nice if you can expand on how it didn't work. Aside from not seeing what you want to see visually happen, what checks did you make to see if the script is actually being included in the page.
For example one check I always do is to bring up that page and do an "Inspect Element" and use the resources tab to see if the the script actually made it to the page. (Chrome or FF; not sure if you can do the same in IE)
Chris Burks
Implementations Technician
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2014 05:19 AM
Not sure if this helps, but Script Includes are used for server side code. UI Scripts are used for client side code, ie, things that will run in the browser.
(Understanding what code runs where was the biggest stumbling blocks I had as a new servnicenow admin.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2014 05:25 AM
Agree with what Charles said, Script Includes are server-side and so there is no need to include them you can just call the Script Include in a evaluate tag.
If you want to include a Client-side UI Script then yes you want to upload it to UI Scripts uncheck it as global and include it with the <script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 11:46 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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2017 11:56 AM
Hello Himabindu,
Your posted script for the script include looks like it queries based on a single sys_id. If that is true then it would be better to use:
gr.get('sys_id goes here')
instead of
gr.addQuery('sys_id', 'sys_id goes here');
The difference would be that instead of searching throughout the database and bring back a list of matching records it just goes and brings back the one record because the sys_id is unique. Also you won't have to use gr.query() along with a looping mechanism as it knows that it will only be one record.