
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 11:53 AM
Hi friends,
I am not a reporting expert. Need help in writing a schedule job for a report to send an email on last friday of every month.
I went to report and then click on schedule, under Run selected monthly and it shows day of the month. Please suggest on how to write a schedule job to send an email on last friday of every month.
Thanks in advance,
Karthik
Solved! Go to Solution.
- Labels:
-
Reporting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 12:48 PM
More details on my solution... Use the script below in your condition:
function isLastWeekOfMonth() {
var report_date = new GlideDateTime();
var days_in_month = report_date.getDaysInMonthUTC();
var day_of_month = report_date.getDayOfMonthUTC();
if (day_of_month >= days_in_month - 6) {
return true;
} else {
return false;
}
}
isLastWeekOfMonth();
More info can be found below:
Scheduled Reports - Condition Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 12:25 PM
I would look into combining a getDayOfWeek() method with a getDaysinMonth() method and then writing a condition script that makes sure the day of the week = 5 (Friday), but that there are less than 7 days left in the month. That will let you know that it's the last Friday of the month and will be dynamic for the changing amount of days in each month.
In your regular script you can workout what you want to happen with firing your email with your report.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 01:13 PM
Hi Michael,
As per your saying, does the script should look like this?
getDayOfMonth > 25 && getDayOfMonth <=31&& getDayOfWeek() == 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 12:48 PM
More details on my solution... Use the script below in your condition:
function isLastWeekOfMonth() {
var report_date = new GlideDateTime();
var days_in_month = report_date.getDaysInMonthUTC();
var day_of_month = report_date.getDayOfMonthUTC();
if (day_of_month >= days_in_month - 6) {
return true;
} else {
return false;
}
}
isLastWeekOfMonth();
More info can be found below:
Scheduled Reports - Condition Script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 01:11 PM
Hi Marcello,
Thanks for responding.
Your script runs if it is the last week of the month. Does it checks last friday of the month?
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 01:38 PM
What if this below condition works? Please let me know if this return the last friday of every month.
getDayOfMonth > 22 && getDayOfMonth <=31 && getDayOfWeek() == 5