Database View and Where Clause calling Script Include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 11:40 AM
Hi,
I thought I understood the couple of examples provided in the community to use an Include Script in the Where clause .. pls see below.
In this very simple example, the expectation is that the script will return a serial number which is then used to against the table to return the one matching record.
This is the Include Script (which, has been dumbed down)
This all fails miserably :<
Can anyone explain why it fails?
And, assuming I can get this notion working, the next question would be do I need to create a unique Include Script for every case where I want to use one? I.e. I can't bundle up a bunch of 'functions' within TOBIncludeScripts() and call them like so ==>
a_serial_number = javascript.TOBIncludeScripts().someOtherFunction()
Thanks in advance!
tony
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 11:46 AM
Could you provide a bit more info about what you're trying to accomplish here? What tables are you trying to join?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 11:58 AM
Sure ...
The long term goal is to generate a bunch of REPORTS, some of which will require accessing multiple tables at once. My understanding is that JOIN means DATABASE VIEW (as you cannot accomplish this directly in a REPORT.)
So as an experiment I JOINed the [alm_asset] with [cmn_locations] using the WHERE of the [cmn_locations] set to alm_assset_location = cmn_location_sys_id.
Then to try out the notion of the Include Scipt, I made the WHERE of the [alm_asset] to be:
a_serial_number = javascript:TOBIncldeuScript()
This script returns one (currently hard coded) serial number which should force the entire View to return One Asset record.
System logs show an error a mile long when I "Try It" with nothing recognizable in the text.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 01:09 PM
So you can use database views to join tables together, but servicenow also allows for the concept of "dot-walking" tables using reference fields. For example if I wanted to show list of CIs and also data related to the locations where those CIs are located I can do that without a database view by dotwalking from the CI to the location table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 01:13 PM
Thanks, Brad, that is good to know !
Regards,
Tony
http://www.sourcecode-llc.com <http://www.sourcecode-llc.com/>
tob@sourcecode-llc.com
office: 843.310.1356
cell: 843.422.3379