- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2020 06:30 AM
Hello,
I have a service portal page with a 'data table from instance definition' widget. It displays records from my 'hours logged' table. I need to use a script to filter the records that it shows, however, I am getting a strange result.
Filter Script:
javascript:var name = name_of_employee;
var date = date;
var getStart = new GlideRecord('x_utsll_time_manag_time_management');
getStart.addQuery('name_of_employee', name);
getStart.query();
if(getStart.next()){
var start = getStart.pay_period_start
};
date > start; //Only records that are after the getStart.pay_period_start date should be shown
name_of_employee=javascript:gs.getUserDisplayName(); //Only records that match the currently logged in user name
RESULT:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2020 08:14 AM
Both javascript statements are valid. So if your name_of_employee is a string field and not a reference, and if pay period end is Date field and not Date/Time, then this looks good.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2020 06:41 AM
Hi JJG,
This out-of-the-box widget is not designed to use a query like such. Only filters like:
active=true^assigned_toDYNAMIC932905532f270090b0c2d5ea2799b6f6^EQ
or
assigned_toLIKEjavascript:gs.getUserID()^EQ
or
assigned_toLIKEjavascript:new test_filter_sp().filter()
etc.
So not sure if you can fulfill your requirement with this. Though, you could use a dynamic filter or javascript or script include like in the examples above. Could that be a possibility?
So if you could set up a Script Include which returns comma seperated string of sys_ids, then you could use that Script Include with code like:
sys_idINjavascript:new your_script_include().your_function()
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2020 08:07 AM
okay, what about this:
name_of_employee=javascript:gs.getUserDisplayName()^pay_period_end>javascript:new GlideDate();
made it more simple by adding the pay_period_end date field to the table that is having its records displayed. Now I just need records where the name matches and the end date is in the future.
Possible?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2020 08:14 AM
Both javascript statements are valid. So if your name_of_employee is a string field and not a reference, and if pay period end is Date field and not Date/Time, then this looks good.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2020 08:17 AM
Thank Mark!
this ended up working for me:
name_of_employee=javascript:gs.getUserDisplayName()^pay_period_end>=javascript:gs.endOfToday()