Allow user to select end date 3 days greater than end date in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 04:11 AM
I have a catalog item, with fields: start date, end date
The end date should always be selected to be 3 days greater than the start date.
Else the form should not be submitted and it should throw error message.
Please help me to achieve this!!
Thanks in advance.
@Maik Skoddow @Mark Roethof @Gaurav Shirsat @ghaing @tltoulson @Ankur Bawiskar @Chuck Tomasi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 04:22 AM
You can achieve this using the UI policy no code:
Please check the below example for the reference:
Please refer this BLOG for more info
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 04:25 AM
Hi @Misbah Sayyed ,
You can create a onChange catalog client script, the script is as follows:
function onSubmit() {
var startDate = g_form.getValue('start_date');
var sd = getDateFromFormat(startDate, g_user_date_format);
var endDate = g_form.getValue('end_date');
var ed = getDateFromFormat(endDate, g_user_date_format);
var diff= ed- sd;
if (diff != 3)
{
g_form.addErrorMessage("End date should be 3 days after the start date");
return false;
}
}
If my answer has helped with your question, please mark it as helpful and correct.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 04:31 AM
Hello @Misbah Sayyed ,
You can use UI policy for date validations.
use conditions like this in your ui policy
For more date validation refer this article.
If this solves your query mark this as correct and helpful.
Regards
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 05:17 AM
you can use UI policy with no script as per what Anand has shared
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader