How to exclude weekends (Saturday and Sunday) in Normal change Planned Start Date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 04:22 AM
Hi Team,
I have requirement to exclude Saturday and Sunday for normal change Planned start date
note: "working days" means Mon-Friday (excluding weekends). We want requesters to at least submit their changes with the following notice. It should apply to Planned start date (no need to restrict the time).
Normal 7 working days
Thank you in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 04:37 AM
you can use before insert/update BR and check the day of week for planned start date
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gdt = new GlideDateTime(current.start_date);
var dayOfWeek = gdt.getDayOfWeekLocalTime();
if(dayOfWeek == 6 || dayOfWeek == 7){
gs.addErrorMessage("Not allowed to select weekend");
current.setAbortAction(true);
}
})(current, previous);
OR
you can also have onChange client script on Planned start date field and check if it's a weekend using GlideAjax
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2023 07:46 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 04:11 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 02:20 AM
Hi Ankur,
Thanks for your reply
sorry for the confusion my requirement is Planned start date is 5 working days , user able to select upto 5 working days today(13/04/2023) to (19/04/2023) but it is counting Saturday and Sunday also.
Thanks in advance .