How can I add my own fields to the calendar?
Most of the formatting of how things look in the calendar is done on the "Calendar Source Data" layout where you specify which field is used for the Summary-- that is the event attribute we show on all the calendar screens. Using a calc for your Summary field lets you show whatever you like on the calendar (perhaps a user's initials and then the event description, for example).
When you integrated the calendar you created a field in your events table called "zscEventSummaryCalc". Edit the definition of that field to include additional fields in the calendar. More here.
You'll find some additional controls inside the script "Format Event Summary --- Edit the Style of the Event Text Here ---"
But on the Day View you have a bit more room and may want to show something besides just the Summary.
You can place any fields from your events table right on the Day view of the calendar, and you can even make these fields enterable if you'd like, but there are a few caveats about that below.
Calendar Versions prior to v7
Calendar Versions > 7
Continue: all versions
Next go to the Day Tab of the calendar in layout mode (see Editing the Calendar Layouts if you don't know how to get to the day tab in layout mode). Then simply add fields from your event table-- that would be a field from Sample Events (versions prior to 7) in the original calendar file or from SampleEventsDirect (versions after 7) .
Next, add a Refresh Window step at the end of the script "Refresh Calendar..." using the the Flush Cached Join Results option. If you want the best possible performance you can wrap it in an "If" statement so this step only executes when $$sc_Mode = "Day Sched". Reason for this is that the "Flush..." part of this will undo some of the work FileMaker does storing cached data from the server, and on some networks you'll feel this as you need to fetch the data over again.
Multiple Data Sources
And, obviously, this only works for one table at a time unless you'd like to set up similar relationships to each of your events' source tables-- if your primary keys are all prefixed, only one relationship will be "true" at a time, so you can stack fields from other events this way. If your primary keys aren't prefixed get in touch with SeedCode as we have some custom solutions that can help with this.
Note that if you allow entry to fields in your events table you may edit information that should cause an event to move or change color. Yet FileMaker won't know to do redraw the calendar just because you edit the field. In such cases you'll need a script trigger on your field (we recommend the OnObjectSave trigger) that will call the script "Refresh Calendar". Don't send any parameters to the script.
Changing fields per tab
Can I show different fields on some views of the calendar?
Yes. The section above describes how you can add your own fields to the Day view, but you can also change what shows up on other views. In this example we'll describe how to set the Month view to show just a field in your events table called "My Field", leaving the other views to show the field(s) you've mapped to the calendar's Summary.
Begin by backing up a copy of your file. ;-)
1. Edit the script "Cast Events as Variables - Build Query" and find comment "Build Query 2". You'll be editing the first Set Variable line after this comment.
2. The calc for that Set Variable line contains a Let() statement in it and that Let sets a variable "f" (for "fields") to the list of fields we'll pull from your events table. That currently ends like this:
Add the following right after the code above:
This adds the field "MyField" to the SQL Query results so you'll have access to it when it's time to draw the month view. Hard coding a literal field name like this isn't usually a great idea as this calc will break if you change the name of "MyField". But this is a fine way to go to just see this working. Once it is working you'll want to go back and replace "MyField" with a custom function that quotes the field and removes the table name, effectively making the field name SQL safe. Kevin Frank has a great such function here: http://www.filemakerhacks.com/?p=4924
You can expand on this calc to include new fields for other modes as well. For your reference, here is a list of all the possible modes in the calendar and the views they represent: Modes In The Calendar.
Note that if you have more than one source you'll want to expand this to include a different version of "MyField" or each source by using a case statement and a different field for each value of $sc_SourceNo.
3. Next edit the script "Read Event Summary by Number ( Number )" and edit the line right after the comment "Summary". Change the first line of the calc used from this:
The numbers 5 and 2 here are the columns from our SQL results; since we put "MyField" after "Status", it's now the 5th column.
4. At this point, MyField will show up on the month view beside the event's time if there is one. If you'd like to remove the time as well, edit the script "Format Event Time --- Edit Time Formats for Events Here ---". Edit the very last SetVariable statement in the script and you'll see that right at the beginning, on the 4th line, we've commented out a line about the Day View. Uncomment this line changing the mode form "Day Sched" to "Month" and you'll have removed times from displaying on the month view.