Best way to determine 90 days ago in Encoded Query

jeremyeperdue
Giga Expert

I have a query for a GlideDialogWindow and I want to filter it to "opened in the last 90 days". What is the best way to accomplish this?

var customerField = g_form.getValue('aFieldOnTheForm')

dw.setPreference('sysparm_query', 'active=true^requested_for=' + customerField + '^query string here');

I went to Incidents to create my filter and get the encoded query, but I found multiple options to accomplish this task. What do you recommend and why?

1 ACCEPTED SOLUTION

Alex North
ServiceNow Employee
ServiceNow Employee

If you build the filter you are interested in the UI, then right click on the breadcrumbs and copy "Copy query", you can see exactly what the platform is submitting to obtain a given result set. In this case:



opened_atRELATIVEGE@dayofweek@ago@90


View solution in original post

3 REPLIES 3

Jim Coyne
Kilo Patron

I think the simplest is "opened_at>=javascript:gs.daysAgoStart(90)".   The nice thing about that is you do not have to worry about the time - it looks at the whole day, starting at 00:00:00.


Alex North
ServiceNow Employee
ServiceNow Employee

If you build the filter you are interested in the UI, then right click on the breadcrumbs and copy "Copy query", you can see exactly what the platform is submitting to obtain a given result set. In this case:



opened_atRELATIVEGE@dayofweek@ago@90


This is the route I had taken before I made this post and am happy with the results. Thank you for helping !