
- 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 01:52 PM
I would combine the script above with the normal form scheduling field (please see image below):
I could easily check whether it is Friday inside the script, but I prefer to check it using the OOTB scheduling function (Run = Weekly, Day = Friday) in order to avoid running it every day. This way it runs only on Fridays, and then it checks whether that particular Friday falls on the last week of the month.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 02:18 PM
Thanks Marcello. I have scheduled it to run tomorrow. I will see if it runs correctly and let you know the result. than you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 02:21 PM
Yes it would also work this way. The only issue that I think he'd run into is in the if statement. If the day of the month for instance was 10, and the amount of days in the month were 31, the if condition would still evaluate to true even though there are more Fridays in the month...at least that's how I'm reading it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2019 04:33 PM
Thank You. Your script worked.