Create a task automatically

#1

Hello
at the moment i’m in the process of testing different software product to help my team with task management.
One thing that is forgotten are tasks that need to be done on a regular basis with different servers. Like check logs for errors and if everything is ok delete the logs.
So i would like to automatic create a task on the first of every month to check the logs. So someone can take this task, complete it and push it in the done column.
Maybe i think in the wrong direction for this problem? What would be the best way to solve this? Or am i right and there is a way by a cronjob to create a task?

#2

Something like this already exists, “Recurring Tasks”, just not based on dates, but instead, events.

https://docs.kanboard.org/en/latest/user_guide/tasks.html#recurring-tasks

Give it a read, and see if that’s what you’re looking for.

But to answer your questions:
Maybe i think in the wrong direction for this problem? No, your needs may be different than others needs, and that’s OK.

What would be the best way to solve this? Automatic Action, if the “Recurring Task” feature does not help you.

Or am i right and there is a way by a cronjob to create a task? Yeah, you could setup something like this with your own custom automatic action, using the EVENT_DAILY_CRONJOB.

#3

Hi creecros. I’m not sure what Sphinx wanted, but what I need is a strictly temporally based recurrence. Something that clone task based on time, and independent of the stage of the last task clone. Something like a cron job would be fine, although I would prefer if it could be done within the website, otherwise only me (the admin) will be able to create such tasks. I want to use Kanboard to “organize my family”, so like 1/2 of the tasks would be “do this every Monday”.

So, could you be a bit more specific about how to go about doing this? I’m new to Kanboard, so I don’t really know where to start…

#4

So, you would need to Create a Task every “Day you chose”?

Are you new to PHP?

#5

I read a book about programming PHP, like 10 years ago (literally); didn’t look all to hard. I could probably manage with some help from Google. I normally code in Java and Python…

#6

It really wouldn’t be that difficult, you might just need to look at a few examples to get the jist of it.

If you were to start a repo, on Github, I’d be willing to help. I just don’t want to DO IT for you, like, you need to try your best first ;p

Quick reference: https://docs.kanboard.org/en/latest/plugins/automatic_actions.html

You’d be using TaskModel::EVENT_DAILY_CRONJOB in getCompatibleEvents()

#7

I understand. I’ll have a look, but maybe first on the weekend. Will post back here if I get stuck. Bye!

#8

Hi. I’ve started looking at the examples, but I’m currently confused about one thing (probably more to come). An event like “TaskModel::EVENT_MOVE_COLUMN” is clearly related to a specific task that is being acted upon, so it makes sense that the task data is in $data of doAction(). But if I only register for TaskModel::EVENT_DAILY_CRONJOB, then I would assume the action would be called once per day, per project(?). So will $data reference no task at all, or will doAction() be called once for every task in that project? If it’s the later case, I can restrict the selected tasks with hasRequiredCondition(), but the system would still go over potentially many tasks. So I assume I get no task at all, and have to select them myself. Searching in Google did not return any example using EVENT_DAILY_CRONJOB.

#9

The event is just the trigger, and unrelated to the event data. If you use EVENT_MOVE_COLUMN, then it will trigger when a task is moved into a particular column, and if you choose EVENT_DAILY_CRONJOB it will run every time the cronjob runs, which you can choose how often that runs. But, both are only triggers and unrelated to the events data.

Take a look at this action: https://github.com/creecros/SendEmailCreator/blob/master/Action/TaskEmailDue.php

The event data is defined bygetEventRequiredParameters() and by user input getActionRequiredParameters()

For creating a task, the only event data you will really need is the project id, so you can figure out where to create the task. You will however need a lot of user input data. If it’s day based time, you also need to figure out how to figure out what day it is and determine if the action should run, in the hasRequiredCondition(array $data).

#10

Here are some helpful hints:
If you are doing this “Weekly”, you can create a dropdown list of days of the week in the getActionRequiredParameters() by simply adding an array in the description. i.e.

   'day_to_create_task' => array('Mon' => t('Monday'), 'Tue' => t('Tuesday'),etc...)`

Now in this instance, there is an array of arrays, so to clarify, the first part 'Mon' is the value saved and the value you will get when you grab that data later on, and the second part t('Monday') is what is displayed, the t() isn’t needed unless you plan to add translations.

You can then grab this user input, and compare to what day it actually is in the hasRequiredCondition(array $data), something like:

 return date('D') == $this->getParam('day_to_create_task');

For your do action, you’ll need to look at the taskCreationModel->create, and figure out what data you need to send to it, to effectively create a task.