how to build query ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi Everyone,
I want to use copy query for below screenshot
but when i do copy query after running i am getting below
"sys_created_onONThis week@javascript:gs.beginningOfThisWeek()@javascript:gs.endOfThisWeek()^work_endONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()^work_startDATE...
but when i use the same by addEncodedQuery
i am getting error
can someone please help help how to fix this issue
Regards
Shabbir Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
It would be helpful to show what the error is and how you are using this, along with the full encoded query. Doing something similar on the pm_project table, my script runs without error. Here's my Project list view filters:
And a quick fix script to test copying the query and using it as an encoded query:
var proj = new GlideRecord('pm_project');
proj.addEncodedQuery("sys_class_nameINjavascript:getValidProjectClasses()^sys_created_onONThis week@javascript:gs.beginningOfThisWeek()@javascript:gs.endOfThisWeek()^work_endONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()^work_startDATEPARTSunday@javascript:gs.datePart('dayofweek','sunday','EE')^work_endDATEPARTSaturday@javascript:gs.datePart('dayofweek','saturday','EE')");
proj.query();
if (proj.next()) {
gs.print('record found')
} else {
gs.print('no records found')
}
Notice the EncodedQuery is surrounded in double quotes since single quotes are used within it, and just to be absolutely clear, it's javascript then the colon symbol in all cases, not the garbage this editor converts that to
