When i wrote last time how i made the birthday alerts app , i wrote, how, because of a property of SLA, the data had to be entered at that time of the day when you want to receive on the desired day. (I know i am being confusing because i am trying to say it all in one line, read the previous post and you will understand). Well now you don’t have to, and have made the logic behind the app mucho simpler. Well, the process flow part is just one activity, apart from start and end, unlike the previous time, when it was like, 7 or 8 activities. It is still 7 fields, and all logics have been moved to actions.
The activity Reminders has a SLA set on it. The time duration is obtained from the field RemindIn. The two actions in this are, one to calculate the time, when to remind and the other one, to send the reminder and reset it for the next round. The changed datamodel is as follows.
The calculations done to get the RemindIn time duration is as follows.
- DayNextYear = (DATE(YEAR(NOW())+1,MONTH(Birthday),DAY(Birthday)))
- DayThisYear = (DATE(YEAR(NOW()),MONTH(Birthday),DAY(Birthday)))
- RemindIn = IF(Birthday>NOW(),(Birthday-TODAY()-1)*24+HOUR((TODAY()+1)-NOW()),IF(DayThisYear>NOW(),(DayThisYear-TODAY()-1)*24+HOUR((TODAY()+1)-NOW()),(DayNextYear-TODAY()-1)*24+HOUR((TODAY()+1)-NOW())))