Build-On Tutorial:

Upcoming Tasks

Upcoming Tasks: Lesson 1

View Upcoming Tasks List

Lesson Overview

The Upcoming Tasks list shows tasks grouped by due date, so the user can easily see the most urgent tasks first. In this lesson, you will first create those groupings (Past Due, Today, Tomorrow, etc.) using calculation fields, and then create the list layout itself. Finally, you will work on scripts to help the user navigate the list.Here is a sneak peak of what you will build:

Step 1 - Create fields for grouping tasks by Due Date

The first step is to create three fields for grouping and counting tasks. One will assign the task to a numbered group based on its due date, another will provide labels for each group, and the third will tally how many tasks are in each group.

  1. Open the Manage Database dialog using the File > Manage > Database... menu item.
  2. On the Fields tab, select the Task table
  3. Add a new field named z_Due_Group. For Type, select Calculation.
  4. In the Specify Calculation dialog, enter the following formula (Set the Calculation result to Number):

Let (

today = Get( CurrentDate ) ;

If (Status = "In progress" or Status = "Pending" ;
Case
(
IsEmpty ( Date_Due ); "";
Date_Due < today ; 1 ;
Date_Due = today ; 2 ;
Date_Due = today + 1 ; 3 ;
Date_Due < today + 7 ; 4 ;
Date_Due < today + 14; 5 ;
""
);
// not pending or in progress so no due date group
""

)
)

  1. Select Storage options for the field, then select the checkbox for Do not store calculation results. This forces the z_Due_Group calculation to check the current date every time it is referenced.
  1. Create another calculation field named z_Due_Group_Description.
  2. In the Specify Calculation dialog, enter the following formula (Set the Calculation result to Text):

    Note: You can change these groups to fit your needs. If you want to show just the next week of tasks, for example, omit the "+14" group. If you want to show tasks about a month out, add another group for “+30.”

Choose (  
   z_Due_Group ;
   "";
   "Past Due";
   "Today";
   "Tomorrow";
   "Next 7 Days";
   "Next 14 Days"
)

  1. To count the number of tasks in each group, create a field named z_Count, of Type: Summary.
  2. In the Options dialog, choose Count of as the function, and ID as the field to count.
  1. Exit the Manage Database dialog to save your changes.

Step 2 - Create Upcoming Task List layout

The second step is to create an Upcoming Task List layout and add layout parts that will be used to group tasks by their due group.

  1. Enter Layout mode using the Edit Layout button in the status toolbar.

    Note: You can also enter Layout mode using the View > Layout Mode menu item, or the keyboard shortcut Command-L (macOS) / Control-L (Windows).
  2. Use the Layout pulldown menu in the status toolbar to switch to the Desktop > Task > Task List layout.
  3. Duplicate the layout using the Layouts > Duplicate Layout menu item.

    Note: You can also use the Manage Layouts dialog (File > Manage > Layouts...) to duplicate a layout. This dialog is also useful for organizing and reordering your layouts
    1. Using the Layout Setup dialog (Layouts > Layout Setup…) rename your layout to "Upcoming Task List”.
  4. Remove the Status field and its label from the layout. Adjust the rest of the fields to occupy the Body of the layout as shown here. Delete the New Task button from the Footer.
  1. Go to the Part Setup dialog (Layouts > Part Setup...) and create three new layout parts by clicking the Create... button:
    1. In the Part Definition window, select Sub-summary when sorted by. Choose the z_Due_Group field. Click OK and choose the option to Print Above.
    2. Follow similar steps to create the next part: a Sub-summary when sorted by the field z_Due_Group, with the option to Print Below the part it summarizes.
  1. Finally, create a Trailing Grand Summary layout part. Confirm that this is what your layout Part Setup dialog looks like, then close the dialog to finish.

Step 3 - Add fields to the layout

Adjust the layout to display the new grouped tasks as a report.

  1. Change the title from “Tasks” to "Upcoming Tasks” in the Header. Also, remove the gray line in the header, above the labels.
  2. If it is not already open, open the Inspector using the View > Inspector menu item (you can also access it using keyboard shortcut Command-I (macOS) / Control-I (Windows)).
  3. Activate the Position tab of the Inspector, which is used for arranging and resizing objects.
  1. Select the label for the layout part Sub-summary (Leading) and set the Height of the part to 64 pt.

    Note: If the units in the Position tab are currently displayed as in (inches) or cm (centimeters), click on a unit label repeatedly to toggle through the units until pt (points) is displayed.
  1. Similarly, set the height of the trailing Sub-summary part to 48 pt, and the height of the Trailing Grand Summary to 64 pt.
  2. Using the Fields tab of the Objects pane, drag and drop the TASK::z_Due_Group_Description field into the layout part Sub-summary (Leading), without a label. This is the title for each due group on the layout. (If the Fields tab is not open, click the Objects pane icon in the status toolbar, then click Fields.)
  1. Activate the Styles tab of the Inspector. Select the Body of the layout and change the style to body List.
  1. Style the Trailing Grand Summary and the trailing Sub-summary part as background Minimal.White.
  2. Style the leading Sub-summary part as background Gray.
  3. Style the z_Due_Group_Description field as txt Minimal.Black.Left.Bold.
  4. Select Insert > Merge Field...
    1. Add the TASK::z_Count field (in the Specify Field dialog select the TASK table from the drop-down menu and select the ::z_Count field) to the right side of the Sub-summary (Leading) layout part.
    2. While the text box is still active, add the word "Total: " to the merge text, so that the complete text reads Total: <<z_Count>>.
    3. Style this object as label List.Right.
  5. In the Autosizing section of the Position tab of the Inspector, set the merge object to have top and right anchors.
  1. So that users cannot edit data from this layout, set the z_Due_Group_Description field to only be enterable in Find mode. In the Data tab of the Inspector panel, navigate to the Behavior section and de-select field entry in Browse Mode.
  1. There is an invisible button behind the fields in the Body part. Double-click on the button open the Button Setup dialog.
    1. Change the script that it triggers to Go To Related Record (context).
    2. Change the script parameter to "Upcoming Task to Task".

      Note: You will edit this script in a later step so that it knows how to navigate when given this parameter. The button will not work properly until you do so.
  1. Use the Text tool in the status toolbar to add the text "No tasks found.” to the Trailing Grand Summary.
    1. Style it as introText Center 1.3pt.
    2. Users should only see this text if no upcoming tasks are found. To achieve that, select the text object and go to the Data tab of the Inspector panel.
    3. In the Hide object when section, set the hide condition to Get( FoundCount ) > 0. Turn on Apply in Find Mode.

Step 4 - Create script to find all upcoming tasks

You will now create a script that will find tasks with a Due Group and sort them.

Note: If you have not worked with scripts before, you will find it helpful to review the Creating and Editing Scripts section of the FileMaker Pro Advanced Help system before starting this task.

  1. Open the Script Workspace (Scripts > Script Workspace…). Duplicate the Template script.
  2. Name the new script "Find Upcoming Tasks". 

    Note: Any time you copy the template script, be sure to amend the comments at the top to fit your current script, and move the script to an appropriate folder.
  3. Add the following steps to your script. Note that the Sort Records order should be first by z_Due_Group and then Date_Due, both in Ascending order:

If [ Get (WindowStyle ) = 3 ]
   # Close Navigation Window if in a card window
   Close Window [ Current Window ]
End If

Go to Layout ["Upcoming Task List" (TASK) ; Animation: None ]

Set Error Capture [On]

Enter Find Mode [Pause: Off]
Set Field [TASK::z_Due_Group ; "*"]
Perform Find []

Sort Records [Restore ; With dialog: Off]
Scroll Window [Home]
Go to Record/Request/Page [First]

  1. Save the script and close the Script Workspace.

Step 5 - Add navigation buttons

Create buttons so users can get to the new report from either the dashboard or the menu.

  1. Enter Layout mode and navigate to the Dashboard layout. 
  2. Duplicate one of the existing navigation buttons by selecting it and then using the keyboard shortcut Command-D (macOS) / Control-D (Windows).
  3. Double-click on the new button to open the Button Setup dialog, and make the following changes:
    1. Change the icon to the one shown below.
    2. Set the name of the button to “Upcoming Tasks”.
    3. Change the script that is triggered to the Find Upcoming Tasks script you wrote in Step 4.
    4. Clear out the Optional Script Parameter:.
  1. Rearrange all of the icons on the layout so they are in a pleasing two row configuration as shown at the beginning of this Step.
  2. To let users navigate to the new layout from the Menu Card, enter Layout mode and navigate to the Desktop > Menu | Card layout.
  3. In Layout mode, double-click any of the menu items to open the Button Bar Setup dialog. Navigate to the last segment in the button bar and then click the plus button to add a new segment.
  1. In the Button Bar Setup:
    1. Set the label for the segment to "Upcoming Tasks"
    2. Set the Action: to Perform Script.
    3. Select the Find Upcoming Tasks script.
  1. Close the Button Bar Setup dialog. Adjust the Button Bar’s height to 300 pt, so that each button is 50 pt.The layout should now appear as shown below:
  1. Use the Exit Layout button to return to Browse mode and review your progress.

    Note: You can also enter Browse mode using the View > Browse Mode menu item, or the keyboard shortcut Command-B (macOS) / Control-B (Windows).

Step 6 - Update task detail card window

A user should be able to quickly see the details of a task from the list, then return to the list. To allow that, you will show the task in a card window over the Upcoming Task List.

You will edit the existing New Task card window layout so it works both as a "New Task" and an "Edit Task" layout. You will also change the scripts that open and close that card window so they work from your new list.

  1. Enter Layout mode and navigate to the Desktop > Task > Task Detail - New | Card layout.
  2. Edit the title so it includes the $$CARD_ACTION global variable as a merge variable: Using the Text tool, click into the title and change it from “New Task” to “<<$$CARD_ACTION>> Task”. You can do this either by typing the characters manually, or by using the menu item Insert > Merge Variable.
  3. A user should see Cancel and Create buttons when an existing task is being modified, and Delete and Close buttons when a new task is being created. To achieve that, you will create two new buttons and apply Hide conditions to each set of buttons. First, duplicate the Cancel and Create buttons.
  4. On the new buttons, change the name on the Cancel button to "Delete" and on the Create button to "Close".
  5. Set the Delete button to perform the script Delete Record and Close Card Window ( type ) with the Optional Script Parameter set to “task”.
  6. Set the Close button to perform the script Save Record in Card Window ( context ) and clear the Optional Script Parameter option
  7. When the user is making a new task, the Delete and Close buttons will be hidden so the user sees the Cancel and Create buttons. To achieve this, you will add a hide condition to those objects.

    Select the Delete and Close buttons, then go to the Data tab of the Inspector. In the Hide object when area, enter the formula:

$$CARD_ACTION = "New"

  1. When the user is editing a task, the Delete and Close buttons should be visible and Cancel and Create will be hidden instead. Select the Cancel and Create buttons, then in the Hide object when area, enter the formula:   

$$CARD_ACTION = "Edit"

  1. Stack the buttons on so that Close and Create are on top of each other and similarly for Delete and Cancel. It does not matter which is on top since only one of each pair will be visible to the user at any given time.
  1. In Script WorkSpace (Scripts > Scripts Workspace) modify the Create Task script by adding these steps near the beginning:

#BUILD-ON ADDITION: UPCOMING TASK
Set variable [$$CARD_ACTION; Value: "New"]  
Set variable [$$CONTEXT; Value: “Task”]

  1. Modify the Go To Related Record ( context ) script by adding the following steps near the end.

    NOTE: See Step 12 for details about the New Window script step.

#BUILD-ON ADDITION: UPCOMING TASK
Else if [$context = "Upcoming Task to Task"]

   #Upcoming Task to Task
   Commit Records/Request [ With dialog: Off]
   New Window [Style: Card; Using layout: "Task Detail - New | Card" (TASK) ]  
   Set variable [$$CONTEXT; Value: “Task"]
   Set variable [$$CARD_ACTION; Value: “Edit"]

  1. In the New Window step:
    1. Set the Window Style: to Card.
    2. Leave the Window Name: blank.
    3. Choose the Task Detail - New | Card layout.
    4. All options should be turned off except Dim parent window.
  1. Modify the Save Record in Card Window ( context ) script by adding these steps near the end of the script:

#BUILD-ON ADDITION: UPCOMING TASKS
If [$$CONTEXT = "Task" and $$CARD_ACTION = "Edit"]
   Perform Script [ Specified: From list ; "Find Upcoming Tasks" ; Parameter: ]
End If

  1. Save all of your scripts (Scripts menu > Save All Scripts) and close the Script Workspace.

Step 7 - Review your work

  1. You should be able to open the Upcoming Task List from both the Dashboard and the Menu and see tasks that are past due or due in the next 2 weeks.   

    Note: Depending on your data, you might not see any upcoming tasks. To best test, make sure you have tasks that fit the upcoming or overdue tasks logic (In Progress or Pending tasks with a past due date, for example).
  2. Tasks should be grouped by z_Due_Group.
  3. You should be able to see and edit the detail of a task in the card window layout, with "Edit Task" as the title. Your exit options should be Close and Delete.
  4. Even though you did not modify the process for adding tasks, you should test this functionality to make sure your other changes did not impact it. When adding tasks, the card window layout should look like it did before this change, with "New Task" still as the title. Your exit options should be Cancel and Create.