7 Replies Latest reply on Jun 12, 2012 8:53 AM by philmodjunk

    Create recurring task?

    KimberlyPerkins

      Title

      Create recurring task?

      Post

      Hello All,

      I am using the starter solution for task management in FM Pro 2010. I would like to create a way to have task re-enter themselves when they are completed. I can make a script to create/duplicate a record of the task when the complete button is pressed. But I cannot figure out how to get the due date of the task to change to the new date. Any suggestions?

       

      Thanks,

       

      Kim

        • 1. Re: Create recurring task?
          GuyStevens

          The question is: How do you determine which task needs to be repeated?

          If some tasks do and some tasks don't you could either:

          - Make another button that says something like "Complete and duplicate task"
          - Or you could make a checkbox that says "Repeat" and then you could make your script to duplicate the task IF the "Repeat" checkbox is checked.

          Then: How do you determine the new date of the new task?
          Is that calculated? Or do you manually need to alter this?

          Let's see how we would do this using the "Repeat" checkbox.

          In your task table create a new text field named "Repeat".
          Put it on your layout and make it a checkbox with one manual value of "Repeat"

          Then change the script that's attached to the complete button.

          I don't know what that script does now, but this is what you need to add:

          - Do whatever steps you need to do to set this task as complete
          - IF [Tasks::Repeat = "Repeat"]
            - Duplicate Record
            - Set Field [Tasks::DueDate ; "Whichever new date you want or a calculation to set the new date. Might need to make a variable before the duplicate to set the date of the previous task )]
            - Commit Records / Request
          - End If

           
          We might still need to calculate the new due date, and that might require either a variable or a calculation based on the date the new task was made.

          • 2. Re: Create recurring task?
            KimberlyPerkins

            Thank you DaSaint. This is helpful. I had quite a bit of it worked out in my head but hadn't written any of it yet. The part I will need the most help with is figuring out to get it to calculate the new date. The quarterly one being the hardest. It's always the last day, of the month, following the end of the quarter. Since there are 30 and 31s as well as a 28 or 29, it's not that easy to figure out. I had an instructor suggest going to the 1st of the month following that date and then subtracting 1. I just don't know how to write the code to get it to calculate dates. 

             

            Kim

            • 3. Re: Create recurring task?
              philmodjunk

              Date ( 3 ; 0 ; 2012 )

              Will produce a date of 2 / 29 / 2012 (I'm using MMDDYYYY format here)

              DateField - day ( dateField )

              Will compute the date for the last day of the month of the month prior to the month shown in DateField.

              • 4. Re: Create recurring task?
                GuyStevens

                You could make a calculation field to calculate the current quarter using a CASE statement:

                Case (
                Month (Get (CurrentDate)) = 1 ; 1 ;
                Month (Get (CurrentDate)) = 2 ; 1 ;
                Month (Get (CurrentDate)) = 3 ; 1 ;
                Month (Get (CurrentDate)) = 4 ; 2 ;
                Month (Get (CurrentDate)) = 5 ; 2 ;
                Month (Get (CurrentDate)) = 6 ; 2 ;
                Month (Get (CurrentDate)) = 7 ; 3 ;
                Month (Get (CurrentDate)) = 8 ; 3 ;
                Month (Get (CurrentDate)) = 9 ; 3 ;
                Month (Get (CurrentDate)) = 10 ; 4 ;
                Month (Get (CurrentDate)) = 11 ; 4 ;
                Month (Get (CurrentDate)) = 12 ; 4 ;
                )

                 

                Then you could relate this to another table "quarters"

                where you make 4 records one for every quarter, and manually set the end date of each quarter.

                This new table has two fields; "Quarter" a number field. And "EndDate" where you manually set the end date for each quarter.

                You create a relationship between the calculation field that calculated the quarter, and the quarter table "Quarter" field. And you can then get the end date from that related table.

                It's maybe not that elegant, but it might work.

                • 5. Re: Create recurring task?
                  philmodjunk

                  A simpler calculation for computing the quarter:

                  Ceiling ( Month ( DateField ) / 3 )

                  • 6. Re: Create recurring task?
                    KimberlyPerkins

                    Hi Guys,

                    Here is what I have so far:

                    Frequency will be a pull down and will be:

                    Once

                    Weekly

                    Monthly 

                    Monthly 15th  (Monthly due on the 15th)

                    Monthly End (Monthly end of month)

                    Quarterly

                    Annually

                    Then although I have created this, I haven't yet added it to the script.

                     

                    The script is as follows, and is from the current, completed, task:

                    Go to field (Tasks::Status)

                    Set Field (Tasks::Status;"Complete:)

                    Duplicate Record/Request

                    Set Field (Tasks::Status;"Open")

                    Go to Field (Tasks:Date_Start)

                     

                    All of this works. Now I need to re-set the start and due dates in the new record. 

                    The task I am using to try and get this to work has a start date of 4/1/12 and a due date of 4/30/12

                    In then using the script code for: Insert Calculated Result (Select; Tasks:Date_Start: Month(+3))

                     

                    This particular code returns the result "1" and no matter what I try, nothing works. This is the part I need help on. What is the code to get the start date to increase to the first of the month, 3 months following the current date.

                     

                    On the Due Date it would be the first of the month, 4 months after current due month, minus one day, to always get the last day of the month. 

                     

                    Thanks for all of your help on this. 

                     

                    Kim

                     

                    • 7. Re: Create recurring task?
                      philmodjunk

                      You can remove the go to field steps. Set field does not require that the focus be set on the target field before it enters data into the field specified in that step. Those added steps do no harm, but they aren't needed.

                      The number 3 is the date for 1 / 3 / 0001 so Month ( 3 ) returns 1, the month number for January.

                      Date fields in Filemaker store an integer for the number of days from 12/31/0000 to the date you see in the field.

                      I'd use this step to update the start date field:

                      Set Field [ Tasks::Date_Start ; Let ( D = Tasks::Date_Start ; Date ( Month ( D ) + 4 ; 0 ; Year ( D ) ) ) ]

                      I try to never use a Script step starting with "Insert" if I can avoid doing so. Set Field is less susceptible to "breaking" due to future updates to your layout because the Insert steps require that the target field be present on the layout and set field does not.

                      You can look up the functions I used in Help if they are unfamiliar to you.