ATF: How to set date values today or empty value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
How to set 'empty' or 'today' value on the Test Run data Set, while the parameter type is Date? If its not possible, what could be the workaround. I need to validate that the field (type:date) value is empty or Today.
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @MaciejM84765360,
The native UI will not fully do this, so a script step ends up being the reliable path.
For setting today dynamically, in the Set Field Values or Test Run Data Set step, enter a scripted value instead of a fixed date, something like javascript: gs.daysAgo(0). ATF evaluates that as a server-side expression rather than a literal string. gs.daysAgo() takes an integer, positive numbers go back in time, negative numbers go forward, so 0 gives you today. Same trick works for gs.daysAgo(-7) if you ever need a week from now.
For setting an empty value, this is the part the standard date picker struggles with, it generally will not let you submit a genuinely blank value. The workaround is to skip that step type for this purpose and use a Run Server-Side Script step instead, clearing the field directly, something like current.your_date_field.setValue('') followed by current.update(). That gives you a guaranteed empty value rather than fighting the UI.
For validating empty or today, the built-in Field Values Validation step only checks one condition per field with no OR logic between two states, so it will not cover this on its own. The workaround again is a Server-Side Script step, where you write the check yourself, comparing the field value against both an empty string and today's date, then pass or fail the test based on that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
Thank you for prompt response. Taking into consideration UI limitations, I think that the Run Server-Side Script workaround could be the best solution in this case.
Maciek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Use "Field value validation" to validate the field date is empty or todays date ( gs.daysAgo(0))
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
It is unable to set the empty or dynamic value in the parameters data set for type of date.
Thanks for the answer.
Maciek
