Skip to main content

How to create a recurring task based on custom values

Creating Dynamic Recurring Tasks in Tadabase

In this article, we’ll walk you through creating a dynamic recurring task in Tadabase. This setup allows you to determine if a task should run today based on specific values in a record. By the end, you’ll have a working equation that dynamically calculates task schedules based on recurrence fields.

This solution can help you run a single task and filter it to only trigger on records that are scheduled to happen today. 

Fields Required

To build this setup, you’ll need the following fields:

  1. Recurring: A field to indicate whether the task is recurring (e.g., a checkbox or toggle).

  2. Frequency: A field to specify how often the task recurs (e.g., 'daily', 'weekly', 'monthly').

  3. Day of the Week: A field to capture the day of the week for weekly tasks (e.g., Sunday, Monday, etc.).

  4. Day of the Month: A field to specify the day of the month for monthly tasks (1-31).

  5. Current Date: An equation field that sets the current date. 

The Equation

Here is the complete equation to determine if today is the day the task should run:

IF({Recurring} = 1 AND {Frequency} = 'daily', 
        1,
        IF({Recurring} = 1 AND {Frequency} = 'weekly' && DAYOFWEEK({Current Date}) = 
            IF({Day of Week} = 'Sunday', 1,
               IF({Day of Week} = 'Monday', 2,
                  IF({Day of Week} = 'Tuesday', 3,
                     IF({Day of Week} = 'Wednesday', 4,
                        IF({Day of Week} = 'Thursday', 5,
                           IF({Day of Week} = 'Friday', 6,
                              IF({Day of Week} = 'Saturday', 7, NULL)
                           )
                        )
                     )
                  )
               )
            ), 
            1,
            IF({Recurring} = 1 AND {Frequency} = 'monthly' &&  DAYOFMONTH({Current Date}) = {Day of the Month},
                1,
                0
            )
        )
    )

Breakdown of the Equation

  1. Daily Tasks:

    • If {Recurring} is checked and {Frequency} is set to 'daily', the task is due today (1).

  2. Weekly Tasks:

    • Checks if {Recurring} is checked and {Frequency} is 'weekly'.

    • Uses DAYOFWEEK(CURDATE()) to determine if today matches the day stored in the {Day of the Week} field.

    • Maps days of the week (e.g., Sunday = 1, Monday = 2) to their respective numeric values.

  3. Monthly Tasks:

    • If {Recurring} is checked and {Frequency} is 'monthly', it checks if today’s date (DAYOFMONTH(CURDATE())) matches the value in {Day of the Month}.

  4. Default Case:

    • If none of the conditions are met, the output is 0 (not due today).

How to Implement

Step 1: Create the Fields

  1. Add a Decision Field field for Recurring.

  2. Add a Select Dropdown field for Frequency with options:

    • 'daily'

    • 'weekly'

    • 'monthly'

  3. Add a dropdown field for Day of the Week with options:

    • Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.

  4. Add a number field for Day of the Month (range: 1-31).

  5. Add an equation field called "Current Date" and set it as CURRENT_DATE()

Step 2: Add the Equation

  1. Navigate to the Equations section in Tadabase.

  2. Create a new equation field.

  3. Copy and paste the equation above into the equation editor.

  4. Make sure you're NOT using the Equations V2
  5. Save the equation.

Step 3: Test the Equation

  • Input various combinations of values into the fields and verify if the equation outputs 1 when the task is due today and 0 otherwise.

Example Scenarios

Recurring Frequency Day of the Week Day of the Month Is Due Today
Yes daily NULL NULL 1
Yes weekly Monday NULL 1 (if today is Monday)
Yes monthly NULL 19 1 (if today is the 19th)
No NULL NULL NULL 0

Conclusion

This setup ensures your tasks dynamically adapt based on the values in their records, making scheduling and tracking more efficient. If you have any questions or need further assistance, feel free to reach out to Tadabase support.