I am trying to run below code, but it shows me this error, what I need to modify?

Madhurya
Kilo Contributor
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?

 

find_real_file.png

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi @Madhurya 

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

View solution in original post

1 REPLY 1

Maik Skoddow
Tera Patron
Tera Patron

Hi @Madhurya 

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