By James Currie, 24 July 2014
When it comes to creating child records records in FileMaker we have a couple of different options available. The first is to enable “Allow creation of records via this relationship” on the relationship graph. This displays an empty set of fields in the last portal row so that the user can enter data and create a record. The second method is to create a button located outside the portal that creates a new record ready for the user to enter their data.
A new feature that we have been using extensively in FileMaker 13 is the ability to conditionally show and hide objects. In this article we will talk about combining the creation of records in a portal row and the conditionally showing and hiding of objects. This will allow us to create a nicer way for users to create records.
Recently we built an iPad solution for a local company; whose sales consultants do onsite visits measuring windows for new curtains and blinds. It’s not unusual for the consultants to measure a window that is much larger than the size of available tracks. The consultant can combine up to eight tracks to cover the required window.
We had to come up with an elegant solution that would allow the consultants to specify the number of tracks to join and at what lengths. We also have limited real estate outside of the portal for an add button. What if we could have a button in the last row of the portal that allowed us to create records?
Using a combination of showing / hiding objects and allowing creation of records through the relationship we can show an add button that appears only in the last row of the portal. Tapping on this will create a record for a length of track. Once we have reached our maximum of eight records the button no longer appears.
First we setup the relationship that we will use for the portal, ensuring that “Allow creation of records in this table via this relationship” is ticked on the portals table occurrence. Next, we define the portal using the relationship that we just setup, adding the fields we want to display into the portal. At this stage the last row will show our fields and allow the user to enter into them to create records.
We can now specify a simple calculation to hide the contents of the last row. We select all the objects that we want to hide in the last row and specify the “Hide object when” calculation to be:
IsEmpty ( Tracks::Track ID )
We could select any field that will have a value auto entered at record creation (eg a record ID). All objects in the last row of the portal with this hide condition defined will now be hidden.
We can now add our button for creating records to the portal. We only have to make one small alteration to our calculation we used to hide the contents of the last row. Simply adding not to the beginning of our calculation will have the desired effect. Our calculation now becomes:
not IsEmpty ( Tracks::Track ID )
Creating the record is simply a case of attaching a script to our visible object. The script simply sets a value into the related field creating a record.
Set Field [Tracks::Interface ID; Interface::Interface ID] Commit Records/Requests 
This technique works nicely when you have a fixed number of child records. If you have a large number of child records your users will be continually scrolling to the bottom of the portal to create new records.
You could use this technique to hide a delete button that would otherwise appear in the last row of the portal (a technique we have demonstrated in the example file). You could also show labels on the second to last row of the portal to aid users in entering the correct data into the fields.
Please find attached an example file. This file is provided to help you fully understand what is going on in this article. Note that FileMaker 13 is required to view this example file.