- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 09:01 AM
I have 3 date fields in a form and I have to ensure all of them satisfy the condition that a date of the past cannot be put in them. How do I implement this in the most concise way?
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 09:19 AM - edited 08-21-2023 09:24 AM
Hi @Aditya Sinha,
If you are working with fields, then create UI policy. If you are working with variables, then create Catalog UI policy.
Condition as:
Date_field1 is AT OR BEFORE Today
Execute if true:
function onCondition() {
g_form.clearValue("Date_field2");
g_form.showFieldMsg("Date_field2", "Past date not allowed" , "error");
}
Date_field2 is AT OR BEFORE Today
Execute if true:
function onCondition() {
g_form.clearValue("Date_field2");
g_form.showFieldMsg("Date_field2", "Past date not allowed" , "error");
}
Date_field3 is AT OR BEFORE Today
Execute if true:
function onCondition() {
g_form.clearValue("Date_field3");
g_form.showFieldMsg("Date_field3", "Past date not allowed" , "error");
}
For reference: No Code date validations through (Catalog) UI Policies
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:49 AM
Hi @Aditya Sinha,
Yes. You need to write 3 UI policies for each field.
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 09:19 AM - edited 08-21-2023 09:24 AM
Hi @Aditya Sinha,
If you are working with fields, then create UI policy. If you are working with variables, then create Catalog UI policy.
Condition as:
Date_field1 is AT OR BEFORE Today
Execute if true:
function onCondition() {
g_form.clearValue("Date_field2");
g_form.showFieldMsg("Date_field2", "Past date not allowed" , "error");
}
Date_field2 is AT OR BEFORE Today
Execute if true:
function onCondition() {
g_form.clearValue("Date_field2");
g_form.showFieldMsg("Date_field2", "Past date not allowed" , "error");
}
Date_field3 is AT OR BEFORE Today
Execute if true:
function onCondition() {
g_form.clearValue("Date_field3");
g_form.showFieldMsg("Date_field3", "Past date not allowed" , "error");
}
For reference: No Code date validations through (Catalog) UI Policies
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:05 AM
Hi @Sagar Pagar do I have to write 3 policies, one for each field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:49 AM
Hi @Aditya Sinha,
Yes. You need to write 3 UI policies for each field.
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar