- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2023 10:51 PM
Hi Community,
I make a date field variable on a catalog page and I need that date selected should be within 2 days from the current date.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2023 11:34 PM
Hi @Deepak Shaerma ,
You can use the UI policy to achieve this.
1. Create a catalog UI policy and use below conditions on your date variable.
Conditions: User not to select the date 2 after days from now and not past date.
2. Script: Give your variable name and msg as per requirement.
function onCondition() {
g_form.clearValue("start_date");
g_form.showFieldMsg('start_date', "Please select date as 2 days from now", "error");
}
Result: Display msg user selects incorrect date.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2023 11:18 PM
Hi,
You have to create Catalog UI policy with condition as
Date_variable relative after 2 days from now
Execute if true:
g_form.clearValue("date_variable");
g_form.showFieldMesaage("("date_variable", "date should be with in 2 days from now", "info");
Execute if false:
g_form.clearMessage();
Thanks,
Sagar Pagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2023 11:20 PM
Hi @Deepak Shaerma ,
You can refer to this discussion : https://www.servicenow.com/community/it-service-management-forum/date-field-should-accept-only-2-day...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2023 11:34 PM
Hi @Deepak Shaerma ,
You can use the UI policy to achieve this.
1. Create a catalog UI policy and use below conditions on your date variable.
Conditions: User not to select the date 2 after days from now and not past date.
2. Script: Give your variable name and msg as per requirement.
function onCondition() {
g_form.clearValue("start_date");
g_form.showFieldMsg('start_date', "Please select date as 2 days from now", "error");
}
Result: Display msg user selects incorrect date.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 02:04 AM
@Pavankumar_1 I need to assign the assignment group to my catalog items. Help me in this..
if my (1) Catalog Item = Laptop so my Assignment group = IT ADMIN
and if Catalog Item = Mobile so my Assignment group = IT Mobile