4 Replies Latest reply on Jun 12, 2015 11:38 AM by JonathanYoung

Calculation or script help - Scheduling over a variable time frame

Title

Calculation or script help - Scheduling over a variable time frame

Post

Have a database which among other things sends out emails to clients. Currently the emails are manually scheduled to be sent out in an even distribution over a variable length of time. What I would like to do is automatically calculate when the emails would be sent out equally distributing them over a variable length of time.

I have Clients and Tips tables. The client table has a "date of travel" field and the tips table has multiple "send on date" fields that are manually populated with a date to evenly distribute the documents that are sent out as attachments to emails. Currently, with the manually populated "send on date" fields, I have a simple script which is attached to a button that checks the "send on date", and the current system date, then sends out the appropriate documents.

There are 25 different documents any number of which may or may not be sent out depending on the client needs. The documents that are to be sent need to go out in a certain order of priority.  That has not yet been done but could be set up with a priority field that has a number value.

For example client "A" will receive 20 of 25 different documents sent by email, there are approximately 100 days between today's date and the date of their travel. Therefore one email should be sent out every four days. Client "B" leaves in 29 days and will receive 11 of 25 different documents therefore one email should be sent approximately every three days.

Any ideas on how to best accomplish this??

I am not a guru - or coder so clarity and explanation is much appreciated.

Thanks!

Jon

• 1. Re: Calculation or script help - Scheduling over a variable time frame

Departure Date - Current date will compute the number of days from now til departure

That value divided by the number of documents to send will compute an interval between document emails in days.

A looping script can then loop through found set of records linked to your client record, one record for each document and compute the "send" date for each such record.

• 2. Re: Calculation or script help - Scheduling over a variable time frame

I did set up that calculation. That results in the days difference fine, but when I try to divide the result is completely off.

Depart date - Get(CurrentDate)       (calculation result is a Number)  Works fine.

Depart date - Get(CurrentDate)/ 15   result is way off!  The depart date is in a related table (client) does that make a difference? I also understand that if that calculation does work it will give me the proper interval, but how do I get that interval to show up as a date in the "send on date" field?

• 3. Re: Calculation or script help - Scheduling over a variable time frame

Basic math problem there. You are dividing the current date by 15 instead of the number of days between dates by 15.

( Depart date - Get(CurrentDate) ) / 15

• 4. Re: Calculation or script help - Scheduling over a variable time frame

That will just help teach me to work with no glasses! Sooo obvious!

Thanks