- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 01:12 PM
I have created a scrolling widget that will show all overdue changes. I want the change to show on this feed only when it has been approved, the completed status is blank and the work start (scheduled change date) is before today. Below I cannot get the bold code to work, it returns changes that are also in the future. I am thinking this has to do with the date/time format.
Feed is below:
Change form field itself (work_start).
The underlined code is working fine as I built the URL using the breadcrumbs. Any help would be appreciated.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var="jvar_chg">
var chg = new GlideRecord('change_request');
chg.addActiveQuery();
chg.addQuery('approval','approved');
chg.addQuery('u_completed_status','');
chg.addQuery('work_start' < 'javascript:gs.daysAgoStart(0)')
chg.setCategory('homepage');
chg.query();
</g2:evaluate>
<g2:scrollable_area height="100px">
<table border="0" cellspacing="2" cellpadding="0" width="100%">
<j2:while test="$[chg.next()]">
<j2:set var="jvar_chg_link" value="change_request.do?sys_id=$[chg.sys_id]"/>
<j2:set var="jvar_chg_list_link" value="change_request_list.do?sysparm_query=approval%3Dapproved%5Eu_completed_status%3D%5Ework_start%3Cjavascript%3Ags.daysAgoStart(0)"/>
<tr>
<td>
<a href="$[jvar_chg_link]">
<span style="padding-right:10px;"><IMG SRC="images/icons/outage_planned.gifx"/></span>
</a>
<a href="$[jvar_chg_link]" class="linked" style="padding-right:10px;">$[chg.number]</a>
</td>
<td>$[chg.assignment_group.name]</td>
<td>$[chg.work_start]</td>
</tr>
</j2:while>
<tr>
<td align="center" colspan="3"><a href="$[jvar_chg_list_link]" class="linked">${gs.getMessage("View all past due Change Requests")}</a></td>
</tr>
</table>
</g2:scrollable_area>
</j:jelly>
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 10:50 PM
use this query
chg.addEncodedQuery('active=true^approval=approved^work_start<javascript:gs.daysAgoStart(0)^u_completed_status=');
reference:
https://demo020.service-now.com/sys_ui_page.do?sys_id=e1b44a2ca51c310057935ab5c4d157e5&sysparm_view=
login using :
https://demo020.service-now.com/login.do
username : admin
password : admin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2014 10:50 PM
use this query
chg.addEncodedQuery('active=true^approval=approved^work_start<javascript:gs.daysAgoStart(0)^u_completed_status=');
reference:
https://demo020.service-now.com/sys_ui_page.do?sys_id=e1b44a2ca51c310057935ab5c4d157e5&sysparm_view=
login using :
https://demo020.service-now.com/login.do
username : admin
password : admin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2014 01:47 AM
I do prefer using encoded queries myself as you can build them in the breadcrumb filter and check your results before running any code.
From testing addEncodedQuery() against addQuery() we noticed that encoded queries run quicker as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2014 01:51 AM
for me, it's just the simplicity to write code that is making me use it every time ...
i dint knew that encoded query runs faster .. good to know thanks !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2014 06:20 AM
Thank you P Kalaiarasan, this worked perfectly!