- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2015 07:01 AM
Hi All,
I have written some SQL queies but it is not working when i checked it with script background , I am getting some errors .
gs.sql("(select category from incident;)"):
[0:00:00.000] Script completed in scope global: script
Javascript compiler exception: invalid label (<refname>; line 1) in: gs.sql("(select category from incident;)"):
if i gives as gs.sql("select category from incident");
[0:00:00.002] Script completed in scope global: script
SQL error: FAILED TRYING TO EXECUTE ON CONNECTION 5: select category from incident Syntax Error or Access Rule Violation detected by database (Table 'dev14756_1.incident' doesn't exist) : no thrown error
gs.sql("(select count (*) ,caller_id.vip from incident where caller_id.vip="true")");
0:00:00.001] Script completed in scope global: script
Javascript compiler exception: missing ) after argument list (<refname>; line 1) in: gs.sql("(select count (*) ,caller_id.vip from incident where caller_id.vip="true")");
What will be the problem with this ?
Please Provide solution.
Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2015 07:14 AM
I think your first and third have some syntax errors, and here's the best sql reference I could find.
http://www.servicenowelite.com/blog/2014/2/1/glidesystem-sql
Why exactly are you using gs.sql() instead of a GlideRecord query, which would be the best practice?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2015 07:51 AM
Just notice something else, you're trying to dot walk in a SQL statement. That will not work in SQL!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2015 07:53 AM
The other input is that i don't believe that caller_id is a field of the task table.
Something like the following one will work:
gs.sql("Select count(*), state from task WHERE sys_class_name='incident' GROUP BY state");
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2015 03:12 AM
Thanks For Your Valuale Inputs Berny Alvarado @brad tilton @tony barratt@gurpreet