How to set an inbound working on weekdays.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2025 10:28 AM
Hello,
I have a scenario to create an inbound action with the following conditions:
When the instance receives an email containing "(CRITICAL)" in the email subject, and
"Integrated Management Log Severity: CRITICAL" in the email body,
Then an incident record should be created.
The tricky part is:
This should only happen on workdays (Monday to Friday).
Emails received on weekends (Saturday or Sunday) must be ignored, and no incident record should be created.
The condition and script I provided are shown below. The inbound action is working, and incidents are being created, but they are also being created on weekends. I need to prevent incidents from being created on weekends.
Thanks in advance!!
- Labels:
-
Ask the Experts

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2025 10:32 AM
Try below code.
(function() {
var dayOfWeek = new GlideDateTime().getDayOfWeekUTC(); // 1 = Sunday, 2 = Monday, … 7 = Saturday
// Only process Monday (2) through Friday (6)
if (dayOfWeek >= 2 && dayOfWeek <= 6) {
// Create or update ticket logic
current.short_description = email.subject;
current.description = email.body_text;
current.insert();
} else {
// Skip creating ticket
return;
}
})();
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2025 10:41 AM
Hi,
How can I check if the incident record is created on weekends? Should I wait until Saturday to send emails??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2025 10:50 AM
Tweak the code to include tomorrow's day to restrict creation of records, if works then code will work for weekend condition as well or else you have to wait I think.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2025 07:34 AM
Hii,
This isn’t working. I tested it on Sunday, but an incident was still created.