Create a record in an entity based on timing frequency

Create a record in an entity based on timing frequency

  

I have a Task entity and a TasksHistory entity. The Task entity holds unique tasks for users to do. Each task has a frequency associated with it. The same task needs to completed according to that frequency. A history of all completed tasks is kept in the TasksHistory entity.


For example:

I have to capture a time sheet every week (this is the unique task but it occurs every week). Every week a record in the TasksHistory entity must be created with the new due date (7 days from when it was last due).

Hi Cassandra,

So what is it where you have problems with? So far you only describe what you want, not what you tried and where you stumbled across a problem implementing your requirements.

Regards,

Daniel

Hi Cassandra


If what you need is way to do this, the answer would be using timers. You can check out how to that over here. Basically, build a server action that creates the entry you need, set it up as a timer, set the timer's schedule (say every Monday at 7:00 am for example), and you're all set. 

You can also run the timer manually or change said schedule from service center without the need of changing any code.


Hope this helps!

  CLSJ

Daniël Kuhlmann wrote:

Hi Cassandra,

So what is it where you have problems with? So far you only describe what you want, not what you tried and where you stumbled across a problem implementing your requirements.

Regards,

Daniel

Hi Daniel,

I am having a problem with creating the recurring task according to the frequency assigned to it (every task has a different frequency). I am struggling to understand how to schedule the timer dynamically according to the specific tasks frequency

Carlos López Santibáñez Jácome wrote:

Hi Cassandra


If what you need is way to do this, the answer would be using timers. You can check out how to that over here. Basically, build a server action that creates the entry you need, set it up as a timer, set the timer's schedule (say every Monday at 7:00 am for example), and you're all set. 

You can also run the timer manually or change said schedule from service center without the need of changing any code.


Hope this helps!

  CLSJ

Thanks Carlos!


I have looked at timers but my problem is that every task has a different frequency (daily, weekly, monthly etc). I am struggling to understand how to schedule the timer dynamically according to the specific tasks frequency



One option might be to create a single timer that runs every day. This timer checks every task to see when it was last done and what it's frequency is, then if the time since it was last done is >= to the frequency it can create a new entry. 

I don't know if this is an optimal solution but it should work.

Cassandra Erdis wrote:



Thanks Carlos!


I have looked at timers but my problem is that every task has a different frequency (daily, weekly, monthly etc). I am struggling to understand how to schedule the timer dynamically according to the specific tasks frequency



I think the best solution in this case would be to have one timer per frequency, so you'd have one timer that runs every week creating the weekly entries, you'd have one timer that runs every day creating the daily entires, etc. 

If you, however still need to change the schedule dynamically, there is a System table called Cyclic_Job_Shared (or Cyclic_Job if your eSpace is multi-tenant) which has an attribute called Next_Run. You can change that attribute to your desired schedule inside the timer's code,

Hope this helps!

   CLSJ