Issue with javascript:gs.daysAgoStart when using addQuery

shawhan1126
Giga Contributor

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:

Screenshot.jpg

Change form field itself (work_start).

Screenshot2.jpg

 

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' &lt; '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>

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

use this query



chg.addEncodedQuery('active=true^approval=approved^work_start&lt;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


View solution in original post

6 REPLIES 6

Daryll Conway
Giga Guru

It looks like you are missing the comma separator.


I think it should be


chg.addQuery('work_start', &lt;, 'javascript:gs.daysAgoStart(0)')


I've never had a problem using the < operator but I know &lt is best practice for SNow


Daryll, I tried with the commas before and nothing shows up at all.