JOB Scheduler should Executed on every last date of the month.
Application Type
Traditional Web, Reactive

Hello All

I have to run one ServerAction on every last day / end of the Month.

For e.g.  Present Month, my Job should be executed on 30-Sept-2021. It should executed every last date of the month

In the same way my Next JOB scheduler should be executed on 31-Oct-2021 and so on.

Can anyone tell me how to achieve this kind of scenario?  

 


Also please tell how to TEST this, as OutSystems is on Cloud Environment so even if we make change local machine date time will not reflect,  how can we test such type of scenario?  


Regards

JK2020

Hi,

A possible solution is to make the timer run daily and as the first thing in the flow, to check if current date is the last day of the month. You can use the output from a component like this, or just use a condition like the following:

AddDays(NewDate(Year(AddMonths(CurrDate(),1)), Month(AddMonths(CurrDate(),1)), 1), -1) = CurrDate()

If it yields True, you continue with your logic, if False, exit the timer.


I'm not sure if I understand your question about testing. OS Cloud Environment's server time is UTC, so you might need to deal with timezone differences indeed. The Timezone component has helpful actions for that. E.g. if you live in a timezone with UTC+2 and want the timer to work at midnight, you would want to set the timer to work at 22:00.

Hello Ozan,

Really thanks for your reply.

Small question, if i apply the below logic in m y application then for Testing should i wait till Last date of the month.  

"AddDays(NewDate(Year(AddMonths(CurrDate(),1)), Month(AddMonths(CurrDate(),1)), 1), -1) = CurrDate()"

Or any option How can I to execute the code before the last date of the month for testing? 

Thanks :)

Regards,

JK2020

Hi JK2020,

You can of course always execute your timer manually from Service Center. This way you can test the code.

Furthermore, stating the obvious: When you run the run e.g.on 22:00h when you're on UTC+2, please remember that the server is still one day behind.

Regards,
Lennart

Hi,\

 I tried to found solution for this and found one article for Timer.


I am not sure how this can implement. Can someone throw light on this solution? How it can be achieved to schedule time on run time. If it is possible then JK2020 definitely you can schedule the next to last date of the month.


Hi Amit,

You basically assign a value to the Schedule property of the Timer during runtime, e.g. to determine its schedule from the next run onwards:

It apparently has a specific format.

I believe the problem is that this Schedule variable doesn't accept specific dates like last day of each month, but rather circular values like '5th day of every month' etc. Last day of month is actually kind of the same, but needs a bit more logic as it's not always the 30th day.

thanks Ozan,

Also, we can do one more thing, we can schedule timer on daily basis and check the current date is the last date then we can proceed to execute the timer whole process otherwise we can end the timer process.

Exactly, that's what I suggested in the first place :) 

Hello JK2020,

Please refer this link as well. Hope this will give an idea how to implement timers.

https://www.outsystems.com/forums/discussion/67217/how-to-automatically-send-emails-on-the-last-day-of-the-month/

Thanks & Kind Regards,

Sachin

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.