Help with Scripting to Filter sys_user Table by Created Column

SN241
Tera Contributor

Hello,

I am new to scripting in ServiceNow and need assistance with 

creating a dynamic filter for a report that extracts data from the sys_user table based on the Created column. I'd like to achieve the following filtering criteria:

  1. A specific date and time (e.g., 2024-01-01 00:00:00)
  2. Wednesday 2 weeks ago
    SN241_1-1721122032135.png
  3. If the current day is Monday or Tuesday, the filter should input the date from 5 days ago. If it is any other day, the filter should input the date from 4 days ago at 23:59:59.
    SN241_0-1721121991644.png

     

Thank you in advance for your assistance.

6 REPLIES 6

SN241
Tera Contributor

Hello @Slava Savitsky and @OlaN,
I created a script to get a specific date. Please see the screenshot below and correct me if I'm wrong.

SN241_0-1721658446834.png


I want to use that script to filter the Created date of Users table, 

  • Created  ON javascript: new Date.getDate(1)
    SN241_2-1721659260368.png
  • Created  BETWEEN javascript: new Date.getDate(1) and  javascript: new Wed2WeeksAgo.getDate(1)

SN241_1-1721658575227.png

My problem now is how to use the created script to filter the table?


Thank you

Okay, well, sorry to disappoint, but date/time field are not available to make dynamic filter like you just described.

You can do most things and filter date/time fields with, for example, a relative time (but it's always relative to the current date, not a date selected user).