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.
Something to say? Post a comment...
Comments
flying pumpkin 07/05/2017 9:41pm (8 years ago)
Hi I am a very new user of filmmaker, this seems to be a basic filmmaker situation that would be in any database I make.
I know this is an old post but how would you implement this in a many to many solution.
For instance I am using this in a database where I have Projects and documents ProjectTable--<Proj_Doc_Join>--Document table. Where lets say Documents contains a container field, ID-keys, and lets say a name. Projects has ID keys and a name. How would this work? I would almost prefer to have the '+' button outside of the table. Is that possible?
Brian Hamm 29/05/2015 3:47pm (10 years ago)
Here's how I get around 'new portal record' behavior.
I have an Expenses table in a database I use for my own freelance (FileMaker) business. I record the date, the amount, and a memo. This table has a "newEmptyRow" calc field, used as the primary sort on the portal. It's a simple calc:
If ( IsEmpty ( ExpenseMemo ) ; "0" ; "1" )
For new expenses, I click a "New Expense" button above the portal, which runs the following:
Go to object [ ExpensePortal]
Go to portal row [ Last ]
SetField [ ExpenseDate ; Get(CurrentDate) ]
Commit Records
Go to portal row [ First ]
Go to Field [ ExpenseMemo ]
Creating a new expense record sets the "newEmptyRow" calc to "0". The date is set, the record is committed, and the new portal row pops to the top because of the empty "Memo" field. The portal also has a secondary sort predicate on the expense date, so everything stays in order, visually, during this process.
I haven't really run into others approaching it this way, so I wanted to share in case it was helpful.
Eric Chiquet 31/03/2015 12:39am (10 years ago)
This is a nice way to create record in a portal.
I'm using the hide/show object in portal to enable or disable modification of record in the portal.
Here's the link where it's explained (if my English is not so good, you can try the French version) :
http://daback.com/index.php?option=com_content&view=article&id=19:show-hide-objects&catid=14&lang=en&Itemid=122
Eric Chiquet
Martin 05/10/2014 8:14pm (10 years ago)
I use this technique in almost every solution, and the "Hide Object When"... is one of my favorite feature on FM 13!!
Jason Gan 10/09/2014 1:14am (10 years ago)
This is beautiful.
thanks
Jason
Karen 28/07/2014 11:17pm (10 years ago)
Nice use of new features!
I've taken to calling the 'empty' row the "potential record" to help explain it to users.
In some cases, I've made a single record top portal to show only this potential record, and whether it's targeted by a "new" button, or the user is just allowed to type to create, it's less annoying that scrolling to the bottom, which users hate.
Alternative is a top row for "most recently created", which couples well with a "new" button. This avoid the frustration of a commit resorting; losing the user's place. Could tie that to user, so "record YOU most recently created".
Nihm Brisby 27/07/2014 10:23am (10 years ago)
Thanks James.
"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."
That filemaker didn't include an option to have the 'new' row first suggests to me the designers haven't done much data entry.
Robert Schaub 27/07/2014 10:08am (10 years ago)
It is nice that we now have the hide feature. But creating related in a portal or not has been around for a long time. As long as you have the allow creation of records ticked on in the relationship. You can create a related record from any where using the set field command. You don't even need to be on the same screen as the portal. As long as you are setting the key field in the relationship.
Daniel Wood 27/07/2014 8:39am (10 years ago)
Hi Jim, thanks for the nice comment :) We had considered adding in the cursor part but left it out at the last minute just for a little simplicity but I agree that really would add to the UI experience.
I am not at Devcon this year but James is there with our CEO Craig so hopefully you'll get to meet them :)
Jim Medema 27/07/2014 1:17am (10 years ago)
Daniel,
If I may speak for the FileMaker developer community and say that we are selfishly glad that you are back from your grand biking adventure! You are an excellent teacher.
Thank you for sharing even the simplest of ideas like this one. It's amazing how a little "twist" can make such a difference in the user experience!
One step I would add to the New Record script is to place the cursor in the field so the user can immediately begin entering data instead of requiring a second click/tap.
All the best,
Jim
PS: Hope to meet you and Jamie Curie at DevCon!
Michele Olson 26/07/2014 12:45am (10 years ago)
Nice technique, James. Thanks for sharing!
James Currie 25/07/2014 9:26am (10 years ago)
Thanks Michael, another good use for this technique.
Michael Rocharde 25/07/2014 3:04am (10 years ago)
Instead of having a button you can just have a single field, showing on the empty row, of the portal that you can type into. As soon as that field is exited, the new record has been created and the rest of the fields in the portal become visible. You can also add a block of layout text (in the portal row) that is only visible, when the record hasn't been created instructing the user to enter data.
Didier Daglinckx 24/07/2014 6:03pm (10 years ago)
Thanks for sharing James !
James Currie 24/07/2014 5:48pm (10 years ago)
Thanks Pedro. Thanks Leo
Stuart 24/07/2014 5:08pm (10 years ago)
Great work James, keep it up
Leo Di Croce 24/07/2014 12:16pm (10 years ago)
Nicely done James. I can use this on a solution I'm working on right now.
Thanks,
=L=
Pedro 24/07/2014 11:55am (10 years ago)
It's a great solution, very beautiful.
Thanks for sharie and teaching us
Regards
Pedro
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments