- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 01:40 AM
I got a task to create an incident on the first working day of the month using flow designer with flow variable , I already have done it using schedule jobs, can some one help me, I am adding script which I have included in the flow variable toggle script section post that creating an incident and trigerring it on Monthly 1 st day at 8 : am`.
```
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 02:21 AM - edited 04-07-2025 02:29 AM
you can run flow on Daily at 8am then check if it's today is first Working day or not
1) create a flow variable of type string
2) use script to get check if today is 1st working day of current month (Monday to Friday), I considered Monday as Start of week and Saturday and Sunday as holidays
var gdt = new GlideDateTime(); // Get the current date and time
var dayOfMonth = gdt.getDayOfMonth(); // Retrieve the day of the month (1-31)
var dayOfWeek = gdt.getDayOfWeek(); // Retrieve the day of the week (1=Sunday, 7=Saturday)
// Check if today is a working day (Monday to Friday)
if (dayOfWeek >= 2 && dayOfWeek <= 6) { // Monday (2) to Friday (6)
// If it's within the first 7 days of the month
if (dayOfMonth == 1) {
gs.info("Today is the first working day of the month.");
return 'true';
} else {
// Check if all previous days are non-working days
var previousDay = new GlideDateTime(gdt);
for (var i = dayOfMonth - 1; i > 0; i--) {
previousDay.addDaysUTC(-1); // Go back one day
var prevDayOfWeek = previousDay.getDayOfWeek();
if (prevDayOfWeek >= 2 && prevDayOfWeek <= 6) {
gs.info("Today is NOT the first working day of the month.");
return 'false';
}
}
gs.info("Today is the first working day of the month.");
return 'true';
}
} else {
gs.info("Today is NOT a working day.");
return 'false';
}
3) then use IF logic to see if that variable is true
4) if yes then create INC
Something like this please enhance further.
I believe I have answered 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-07-2025 03:00 AM
are you creating a flow action to check today is 1st working day of month?
Not required.
I informed to use flow and flow variable and also shared the flow logic
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-07-2025 01:50 AM
Hi @mishrarakes ,
If you're using a flow, then don't need any Scheduled job or script ideally to achieve your requirement, you can simply do the following:
Use the trigger condition as scheduled monthly on 1st day.
Use OOB actions to create the incident record and fill in the required fields for the incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 02:08 AM
It should create on first working day of the month i.e Mon - Friday not sat sun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 02:21 AM - edited 04-07-2025 02:29 AM
you can run flow on Daily at 8am then check if it's today is first Working day or not
1) create a flow variable of type string
2) use script to get check if today is 1st working day of current month (Monday to Friday), I considered Monday as Start of week and Saturday and Sunday as holidays
var gdt = new GlideDateTime(); // Get the current date and time
var dayOfMonth = gdt.getDayOfMonth(); // Retrieve the day of the month (1-31)
var dayOfWeek = gdt.getDayOfWeek(); // Retrieve the day of the week (1=Sunday, 7=Saturday)
// Check if today is a working day (Monday to Friday)
if (dayOfWeek >= 2 && dayOfWeek <= 6) { // Monday (2) to Friday (6)
// If it's within the first 7 days of the month
if (dayOfMonth == 1) {
gs.info("Today is the first working day of the month.");
return 'true';
} else {
// Check if all previous days are non-working days
var previousDay = new GlideDateTime(gdt);
for (var i = dayOfMonth - 1; i > 0; i--) {
previousDay.addDaysUTC(-1); // Go back one day
var prevDayOfWeek = previousDay.getDayOfWeek();
if (prevDayOfWeek >= 2 && prevDayOfWeek <= 6) {
gs.info("Today is NOT the first working day of the month.");
return 'false';
}
}
gs.info("Today is the first working day of the month.");
return 'true';
}
} else {
gs.info("Today is NOT a working day.");
return 'false';
}
3) then use IF logic to see if that variable is true
4) if yes then create INC
Something like this please enhance further.
I believe I have answered 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-07-2025 02:37 AM
Hello ankur, thanks for your guidance but I am not getting script option inside add action i tried many times before also , can i add script inside set flow variable script section