- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 09:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 09:25 PM
it depends on logged in user's date format.
what validation are you planning to run? you can tweak it to ensure it works in all formats.
share the business requirement and what's currently configured
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 09:49 PM
The scenario is that the selected date should be at least 7 days from the current date. I have written a Script Include and a Client Script for this. However, even when I select a date within the allowed range, it still throws an error when the date format is dd/mm/yyyy. But when I impersonate another user, it works fine when the format is yyyy/mm/dd. this might be because dateDiff is only working correctly with the yyyy/mm/dd format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 09:54 PM
no scripting required. you can simply use UI policy and you need not worry about the date format
No Code date validations through (Catalog) UI Policies
use this in UI policy condition
Your Date relative before 7 days from now
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 09:31 PM
Hi @Rishabh_N ,
You can use below script to format date field:
var date = new GlideDate();// replace new GlideDate() with the incoming date
var dateNew = date.getByFormat('yyyy/MM/dd'); // now use the dateNew to set the field value
Regards,
Suraj