I need to allow user onlt to select date that is one week later.

niveditakumari
Mega Sage

Hi, 

 

I need to allow user only to select date in date field that is one week later from today date. I have created one field that is date type field in catalog item. 

I need to allow user only to select date that is 1 week later from today date. 

Can anyone please help me to achieve that. 

 

Regards, 

Nivedita 

 

 

3 ACCEPTED SOLUTIONS

J Siva
Tera Sage

Hi @niveditakumari 
You can create one Catalog UI policy to do the validation.
PFB.

JSiva_0-1741775230240.pngJSiva_1-1741775246736.png

 

JSiva_2-1741775282310.png

 

Hope this helps.
Regards,
Siva

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@niveditakumari 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

Juhi Poddar
Kilo Patron

Hello @niveditakumari 

You can achieve this requirement using UI policy

Refer the screenshot for more details:

Ui Policy Configuration:

JuhiPoddar_0-1741776132115.png

Ui Policy script to show error message:

function onCondition() {
	g_form.showErrorBox('date',"Please select date after 7 days from today");
}

Result:

JuhiPoddar_1-1741776278516.png

JuhiPoddar_2-1741776301479.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

View solution in original post

13 REPLIES 13

J Siva
Tera Sage

Hi @niveditakumari 
You can create one Catalog UI policy to do the validation.
PFB.

JSiva_0-1741775230240.pngJSiva_1-1741775246736.png

 

JSiva_2-1741775282310.png

 

Hope this helps.
Regards,
Siva

Hi @J Siva

 

Thank you. It is working as expected. 

Can you please make me understand condition which you have added in ui policy date relative before 7 days from now, it should after or before. 

Can you please make me understand that condition. 

 

Regards, 

Nivedita 

 

 

 

Hi @niveditakumari 

The condition "relative before 7 days from now" means the selected date must be earlier than 7 days from now.

We want to show the error message if the date is selected within the next 7 days and that's the reason it should be before.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

Hi @J Siva

 

I need to allow user to select date after 7 days but it should calculate only business days not weekend. In our project as per client we follow Friday, Saturday as weekend and I need to exclude Friday, Saturday. When user select date then it should calculate for Sunday, Monday, Tuesday, Wednesday, Thursday as business day.  

Can you please help me with that. 

 

Regards, 

Nivedita