How to call a function declared in a Scoped Script Include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 05:59 AM
I have created a script include named 'iban.js'. It's API Name is 'sn_hr_sp.iban.js'. The content can be found here https://github.com/arhs/iban.js/blob/master/iban.js
Now how do I call it in another script include in the same scope?
When I add the code to the same script include, all I need to do is call IBAN.isValid(value) and it works, but what should I do when the code is in another script include? How do I call the code? 😕
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 06:01 AM
Hi Peter,
Script include has a field called 'Access From', you can select 'accessible form all scopes' on this and then i think ypu would be able to call it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 06:06 AM
I tried changing that, but that did not work. Though that should not be the issue as both script includes are in the same scope.
Edit: It did not work, because the value would not change. I cannot put the script include into 'all scopes'. Not sure why, but as I said, it should not be a problem as both are in same scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 06:12 AM
Edit: The following script works when I put it in the global scope. So I guess I'm missing scope identifiers somewhere 😕
gs.include('iban.js');
gs.print(IBAN.isValid(''));
This returns 'false'.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2017 12:17 AM
you'll have to prefix the call with the scope name (<myscope>.IBAN.isValid()).
See also: http://wiki.servicenow.com/index.php?title=Scripting_in_Scoped_Applications#gsc.tab=0