73
Views
8
Comments
Set up TimerEvent for all data in the database
Question

Hi all,

I'm currently working on a Task Management. When the deadline of a task has passed, its status should turn into "Deadline passed". The Task Manager should check every night, if the deadline has passed or not.

I built a logic for that. My problem is, to implement the logic into a timer. I select the logic in the field "Action" and want to select all tasks of the database in the field "Tasks". But I'm stuck doing it, because it gives me error messages all the time.

Here you can see my logic "Change_Status" and in the right column the fields of the timer.

Thanks a lot for your help and have a great day.

2019-02-14 10-34-42
Plácido Miranda

Hi Raphael,


You can create other action between the timer and the change status action. 


This new action should not have any input parameters. There you can query the takss, create a foreach and for each task call the change status action.


King regards,

Plácido

2021-03-05 13-56-11
Ricardo Pereira
 
MVP

Hi,


You can make an SQL advanced were you select all tasks with the deadline passed (need to see if you need more filters because of all conditions, p.e. the previous status) and updated them all for the new status. With this you perform a bulk operation that is much more eficient that the foreach iteration. 

With that you don't need to make more code in your action that the timer is running and don't need input parameters.


Hope this can help!


Best regards,

Ricardo M Pereira

2019-09-26 16-52-34
alexmr

Hi Raphael,

Here is my suggestion.


1 - Create task and status tables (you should already have)

2 - Create a "ChangeStatusDeadlinePassed" server action. In this server action you will only get delayed tasks with a status other than "deadline" and update status for "past deadline"


3 - Create a stopwatch once a day


UserImage.jpg
Raphael Peck

Thanks a lot for your detailed answer. I did it the way you explained. But in the server action, I can only have GetDelayedTasks.List.Current.Tasks as source. If I try using GetDelayedTasks.List.Current.Tasks.Id, it shows the error message "'Tasks' data type required instead of 'Tasks identifier'".

Do you know why I can't have the id as source in my case?

2018-10-29 08-31-03
João Marques
 
MVP

Hi Raphael,


When an action is expecting a record, you can also define its attributes since a record is a set of attributes and its values. In order to do specify the value of each attribute of a record as done in Alexandre's example, you need to expand the source by hovering the left space behind Source and clicking on the + sign it will appear, as on the image below:


Regards,
João

2019-09-26 16-52-34
alexmr

Raphael,


Could you send me the code?

Attach the oml file.

UserImage.jpg
Raphael Peck

see attached. Thanks a lot

TaskManagerv3.oml
2019-09-26 16-52-34
alexmr

Please, check the the action change_status2. 


You do not need pass a task into input parameter because this method works for all tasks. 


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