コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
10734 ビュー

I want to create a server action that automatically set the deadline of a task in 7 days from today. I already succeed to create a server action that sets today as the deadline date by using the Action Type Write Object and writing the following formula in the deadline field:

time.strftime('%Y-%m-%d %H:%M:%S')

As I am not programmer and do not not any phyton I am struggling to find the formula for today + 7 days

アバター
破棄
最善の回答

Based on the standard Python time package, you could use the following formula instead:

time.strftime('%Y-%m-%d %H:%M:%S',time.gmtime(time.time()+7*24*3600))

The time offset of 7 days is provided in seconds as 7*24*3600, so you can adapt it as needed, positive or negative.

アバター
破棄
著作者

Works. Thanks a lot!

In version 14 this action is not working anymore. Is there any possibility how to overcome it? The error code: <class 'AttributeError'>: "'wrap_module' object has no attribute 'gmtime'" while evaluating

"time.strftime('%Y-%m-%d %H:%M:%S',time.gmtime(time.time()+7*24*3600))"

In V14 in a Automated Action, you can use something like this:

delta = datetime.timedelta(days = 7)
today = datetime.datetime.today().date()
deadline = today + delta

最善の回答

For all the other users, here are the steps to follow in order to automatically set deadlines on Tasks.

  1. From the task kanban or list view, create two advanced filters for each stage: Stage is equal to stage_name, Stage is not equal to stage_name.
  2. In Settings > Technical > Automated Actions, create a new record for all the stages for which you want to set an automatic deadline:
  3. Name: i.e. Set task's deadline to D+7 when stage = New
  4. Model: Task

CONDITIONS TAB:

  • Before Update Filter (pre-condition): retrieve the created filter "Stage is not equal to stage_name" in the list. If you want to add a deadline for the first stage (i.e. New), do not add this pre-condition in the automated action dedicated to the first stage, otherwise it won't work. Further, add "['date_deadline', '=',False]" in its post-condition filter domain in order to avoid an infinite loop. Indeed, without pre-condition, the post-condition would be always valid.

  • After Update Filter (post-condition): retrieve the created filter "Stage is equal to stage_name" in the list.

ACTIONS TAB:

Create a new action:

  • Object: Task

  • Action type: Write object

Field mapping:

  • Model: Task

  • Destination: Deadline

  • Type: Formula

  • Value: time.strftime('%Y-%m-%d %H:%M:%S',time.gmtime(time.time()+7243600))

You can change the number of allowed days by replacing 7 in the formula (7 days).

Enjoy!

アバター
破棄
関連投稿 返信 ビュー 活動
1
2月 24
531
1
5月 24
2089
0
8月 20
2282
0
12月 15
4287
0
4月 24
416