I've in the past had to write some... cludgy date comparisons. I'm not proud of them. I'm just glad I didn't have to look at them later.
Had I thought about what Mark Ragavan wrote about, it would have saved me probably days over my development time in the last 10 years.
Really, theres some common types of checks and actions for dates.
- Is it in the past?
- Is it within a window? e.g. After 7 days from now.
- Is it after another date on the form?
To show this I'll add some reproduction steps below. Start out with my ATF Scoped App;
- On your PDI import my "ATF" scoped app.
- Change scope to "ATF"
- Goto maintain items, and look for "Test Item"
Now that you're here we can quickly test this out.
Disallow past dates
- Create a UI Policy with the condition,
Date Before Today.
- Add a UI Policy action for the field
Dateand check the
- Update the variable
Example textof "Date cannot be in the past."
Try it out.
Now that you've seen it, it should be pretty clear how to apply this to a number of different situations. I just wanted to share as this is a great way for me to remember.
Further Reading: No Code dates validations thru Catalog UI Policies