Javascript for reference qualifier on date field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 04:11 PM
Hi,
I'm currently struggling with getting a reference qualifier to work with JavaScript and hoping someone might be able to help. I have a table of sporting fixtures that includes fields for sport, country, start date and tournament. I would like to prompt the user for a country and date on the catalogue item and show a list of tournaments for them to select from (sport will be hard coded to Tennis and ruleset to Women). I have added the country and date variables to the catalogue item definition. For the tournament variable, so far I have this working..
javascript:'u_sport=Tennis^u_ruleset=Women^u_country='+current.variables.country
but I'm not sure how to add the date condition to this. I have run a filter on the table and retrieved this query but not sure how to convert the string.
u_sport=Tennis^u_ruleset=Women^u_country=d44c63c037a417403842138943990e2c^start_dateON2019-03-13@javascript:gs.dateGenerate('2019-03-13','start')@javascript:gs.dateGenerate('2019-03-13','end')
The fixture start date in the table is stored as a datetime but I only need to prompt the user for a date.
Please would someone be able to assist me this, I would be very grateful.
Mike.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2019 05:55 PM
Try this:
u_sport=Tennis^u_ruleset=Women^u_country=d44c63c037a417403842138943990e2c^start_dateON2019-03-13@javascript:gs.dateGenerate('2019-03-13','start')@javascript:gs.dateGenerate(current.variables.end_date,'end')
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2019 09:45 AM
Thanks Paul, tried this but still not working. I think the first date needs to be variable as well. Also because it's passed as a string, I think it needs to exit out of the string before the variables. Have tried this also but can't get it to work...
javascript:'u_sport=Tennis^u_ruleset=Women^u_country='current.variables.country+'^start_dateON@javascript:gs.dateGenerate(''+current.variables.fixture_date+'','start')@javascript:gs.dateGenerate(''+current.variables.fixture_date+'','end')'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2020 06:27 AM
Did you get this to work? I'm looking to do something similar-