- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2022 09:08 PM
var gr = new GlideRecord('cmdb_ci_computer');
gr.addEncodedQuery('sys_created_onBETWEENjavascript:gs.dateGenerate('2019-09-01','00:00:00')@javascript:gs.dateGenerate('2021-04-13','23:59:59')');
gr.query();
gs.print(gr.getRowCount()); // counts all the active incidents and prints the number
I am trying to run this code in my background scripts, it shows me this error, how can I fix this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2022 09:11 PM
Hi
problem is the line with
gr.addEncodedQuery(' ... ');
As there is already the sign ' within the query you have to enclose the string with quotation marks like this
gr.addEncodedQuery("sys_created_onBETWEENjavascript:gs.dateGenerate('2019-09-01','00:00:00')@javascript:gs.dateGenerate('2021-04-13','23:59:59')");
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2022 09:11 PM
Hi
problem is the line with
gr.addEncodedQuery(' ... ');
As there is already the sign ' within the query you have to enclose the string with quotation marks like this
gr.addEncodedQuery("sys_created_onBETWEENjavascript:gs.dateGenerate('2019-09-01','00:00:00')@javascript:gs.dateGenerate('2021-04-13','23:59:59')");
Kind regards
Maik