How can I show records from more than one table in the same calendar?
Traditionally a portal can only show records from one table occurrence, though it can include fields from other table occurrences related to the one the portal is based on.
DayBack, however, can include events from completely unrelated tables--each of which becomes a "data source" for the calendar. In this way you might have one source be an events table holding things like followup calls, meetings, etc. And have a second source for your jobs table where you show job due dates on the calendar.
The calendar ships with an example second source, a To-Do List, to show you how this works. You can toggle this second source off and on by visiting the "Calendars" tab in the calendar's left hand sidebar.
You can even have multiple sources from within the same table: if, for instance, you had a job due date in your jobs table and a followup date in your jobs table, you'd create those as two separate sources.
Note that having multiple sources can show up in the calendar's speed as there are more records to draw, and additional Find requests to perform: displaying fewer events at one time will always be faster. So you can have as many sources as you want, but try not to show them all at once by default.
How does the calendar decide which source to use for a new event?
First, if there is only one source showing, when you create an event the calendar will create it in that source.
When multiple sources are showing we look to see if the "default sources for new events" is one of them. If it is, we create the event in that source. You can specify this default source toward the top of the script "Load Calendar Settings - On Startup --- Edit Configuration Here ---".
If this default source is not one of the ones showing, we create the event in the first source showing.
So that's what happens when you just ask to create an event without specifying anything further: that is, when you double-click in the calendar. The calendar does, however, have an API that will let you make your own "+" button to create events in any source you want. You can use this to make a "new todo" button, for example. You'd do this by calling the script "Create Edit Delete Event ( SourceNo )..."
Read the comments at the head of that script to learn more about how to use it to make new events.
Creating a New FileMaker Source
Each source in the calendar is represented by a layout. You'll see a couple of these layouts in the calendar's example file: they are names "Source No 1" and "Source No 2". Any new sources you create will need a layout named the same way.
Here is how you'd create a new FileMaker source...
Self = Time ( 24 ; 0 ; 0 ) ; Time ( 24 ; 0 ; 1 ) ;
Self = Time ( 0 ; 0 ; 0 ) ; Time ( 0 ; 0 ; 1 ) ;
Self > Time ( 24 ; 0 ; 0 ) ; Self - Time ( 24 ; 0 ; 0 ) + 1 ;
How do I determine which sources show up by default?
Edit the script "Load Calendar Settings - On Startup --- Edit Configuration Here ---" and find the comment "Which sources are active by default". If you want your source to be shown in the calendar at startup, add its number to the List () function after that comment. If you don't do anything here your source will show up as a possible source on the Calendars tab, but its events won't show in the calendar unless a user elects to click on that source.
Can I have multiple sources from the same base table?
Yes! You might want to, for example, display two distinct sets of Dates/Times from a Jobs or Projects table. (However, in many cases, using a related table to handle multiple dates makes the most sense. For more info on this, see step 1 of Quick Integration).
If you haven't already, follow the Integration instructions to add a source using your first set of Date/Time fields. With the one source working, duplicate the "DBk_WebViewerSource" field twice (one for each source). With the To-Do List set as Source Number 2, let's call these fields "DBk_WebviewerSource1" and "DBk_WebviewerSource3".
Since you've already set up the first source, DBk_WebviewerSource1 does not need any modification. Now, map the appropriate date and time fields in the DBk_WebviewerSource3 calc. Make sure that the sc_sourceNumber variable matches your new source number. Next, modify the original DBk_WebviewerSource field as a Case statement, like so:
We also need a set of DBk_TimestampStartCalcNum and DBk_TimestampEndCalcNum fields for each source. Rename the fields by appending "1" to each field name (these will continue to be used for source 1). Then duplicate them, naming the duplicates DBk_TimestampStartCalcNum3 and DBk_TimestampEndCalcNum3. In these calc fields for source 3, map the date and time fields that correspond with this source.
With the fields set up, completing the addition of the second source is much like adding a source from another table (although a bit easier). Duplicate the Source No 1 layout and rename it Source No 3. Map the date, time, and DBk_TImestamp fields that correspond with this source. Since the same base table occurrence is used for this source, no other fields need to be remapped, unless you have Status or Resource (or other) fields uniquely corresponding to these dates.
Lastly, update the Settings scripts as described in steps 4 and 5 above, and run the Upon Opening script. Your records from this table will be available on the calendar twice!
How can I delete a source or hide it from some users?
All you need to do is change the name of the Source No 2 layout to "Unused No 2". And then quit FileMaker and reopen DayBack.
It can be a little confusing because the source descriptions are stored as global variables and these can hang out, once defined, until you close the solution and reopen it. But DayBack's script "Load Source Settings at Startup --- Describe Your Sources Here ---" looks for the layout's containing "Source No" in their name so changing the name short circuits this while leaving the code in place so you can easily add that source back if you'd like.
If you wanted the source to only show up for some users, you could wrap the "Source No 2" section in the script "Load Source Settings at Startup --- Describe Your Sources Here ---" in an If() statement so that source was only described for some users.
Can I toggle on/off sources within a script?
This is not currently a built-in option, but you *can* override which sources get loaded into the calendar. Since this customization won't actually toggle the active sources in DayBack's sidebar, it's best implemented only when you've added a custom sidebar.
First, within the "Load Calendar Settings - On Startup" script, make sure all your sources are set to active (see "How do I determine which sources show up by default?" section above).
Then, modify the "Event Find" script by adding a Set Variable step just after the $assign_parameters Set Variable step. This step should set the $$sc_SourcesActive variable to the list of your desired active source numbers, so this will depend on how you're tracking/choosing which sources should appear active.
With these changes added, you'll be able to script which sources are "active" without needing to manual toggle sources on the built-in calendar sidebar.