I'm trying to set up a button that resets the dates to today. However, I can't seem to make daterangepicker.setStartValue()
work.
I've tried with the transformer, a Query JSON with SQL and a Run JS Code resource - all with no result.
What's weirder, the docs say I should be able to do this!
https://docs.retool.com/docs/scripting-retool#daterangepickersetstartvaluestring--date
jnui
April 14, 2021, 3:27pm
2
I was curious, so I added a daterangepicker , then made a new js query, and it worked immediately for me.
even code completion was working
daterangepicker1.setStartValue(moment())
My query runs successfully, but the value isn't changed. Did it actually change the start value @jnui ?
jnui
April 14, 2021, 3:44pm
4
actually no, I don’t believe so.
I set it to add 5 days, moment().add(5, ‘days’)
and it did nothing
setting within the inspector works ok, {{ moment().add(5, ‘days’) }}
but not in the script.
jnui
April 14, 2021, 3:51pm
5
I don't know if this helps, but it does work by utilizing the inspector fields
see screenshot
That’s a bummer - on the one hand I’m glad it’s not me. On the other hand I wish that it was working for you and you had a quick fix for me. #sigh
Well, hopefully somebody at Retool will see this soon.
Hiya!@mathfour & @jnui try setting the format like this -daterangepicker1.setStartValue(moment().format('YYYY-MM-DD'))
LMK if that works for you!
Nope - I get a successful message, but no change in the actual daterangepicker date.
However, I DO get this interesting alert:
Hi mathfour, The unexpected token error is coming from a wrong character in the date format input. I think this is an issue with our forum software replacing characters when it is not in a code block. That being said, I tested the script below and it worked. The correct code snippet is:
daterangepicker1.setStartValue(moment().format('YYYY-MM-DD'))
vs.
daterangepicker1.setStartValue(moment().format(‘YYYY-MM-DD’))
More context on this here: https://practicaltypography.com/straight-and-curly-quotes.html
Before, with the invalid characters, you can see that a yellow underline shows an error in the script.
I'll see if we can fix this in our forum software and hope this helps!
Grace
1 Like
Thanks @retool_team ! That is so weird - I retyped them and voila! it works.