Calling scoped script include via global workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 10:01 AM
I'm trying to call a script include from a scoped application within a global workflow (which is for a catalog item). Once the workflow marks the catalog item as approved, a run script is called and is trying to run a function from the script include of my scoped app (creates a related record within the scoped app due to the catalog item being approved). However, I'm not getting anything -- including in gs.debug() which makes me think its not being called. Am I missing something here? I am getting 1 row count on the query so I know i'm inside the while loop:
createTimecards();
function createTimecards(){
// gs.include('x_usdo2_time_att.TimeAttUtils'); -- I tried adding this as well to no avail
var user = current.request.variables.requested_for;
var time = new x_usdo2_time_att.TimeAttUtils(); // workflow in global scope so I called the scoped app prefix
var ts = new GlideRecord('x_usdo2_time_att_timesheet');
ts.addQuery('user', user);
ts.addEncodedQuery('approval!=approved');
ts.query();
gs.log('Row Count is ' + ts.getRowCount());
while (ts.next()){
time.generateAltSchTimecard(user,ts.pay_period,ts.sys_id,current.sys_id); // This is called within the scoped app via an UI action and works without issue
}
}
- Labels:
-
Service Catalog
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 10:03 AM
Hi Cary,
Can you go to the script include and make sure that the "Accessible from" is set to "All application scope"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 10:06 AM
Cary,
In order to call a script include function, you have to use a GlideAjax function, that I cannot see in the script above.
That is why your function is not being called.
Please refer to the thread below :
http://wiki.servicenow.com/index.php?title=GlideAjax#gsc.tab=0
Kind regards,
ZA
Do not feel shy to mark correct or helpful answer if it helps or is correct

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 10:09 AM
Hi AKb,
GlideAjax call is required to make a call from the client side. However the above code is at server and it should work.
Please let me know if I am missing anything here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2016 11:08 AM
Pradeep,
Thanks for your reply! This is indeed available to all application scopes. I didn't think of that when i posted the code but i've used this quite a bit from global side so this has been set for quite some time.