The CreatorCon Call for Content is officially open! Get started here.

Database View and Where Clause calling Script Include

tobrien
Kilo Guru

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.

Screen Shot 2016-09-20 at 2.31.07 PM.png

This is the Include Script (which, has been dumbed down)

Screen Shot 2016-09-20 at 2.31.21 PM.png

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

5 REPLIES 5

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Could you provide a bit more info about what you're trying to accomplish here? What tables are you trying to join?


tobrien
Kilo Guru

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.


Brad Tilton
ServiceNow Employee
ServiceNow Employee

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.



Dot-walking


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