No trick required. The first portal record should not need any special handling.
Any chance that there's a blank record showing in your portal that was created previously?
Thanks so much for replying!
There should not be any blank record showing in the portal.
Even when i create a brand new blank record, the first line on my new portal is still blank. The serial number will not fill in on the second line, third etc until I fill in another field on that line.
I re-read your original post and now realize that I misunderstood your description of the issue. Check these details that I am assuming are true for you. If so, the following explanatinon applies.
- All creation of records via this relationship is enabled for the portal side of the relationship in Manage | Database | Relationships.
- The serial number field that you are referring to in the number field that serves as the match field in the above relationship.
If true then this is normal behavior. When you enter data in fields in the portal row and then commit the record by exiting that portal row, Filemaker creates a new record and item 1 above triggers the automatic entry of the serial number in your related portal record that matches the parent record current in your layout's table. This normal behavior. Filemaker can't enter this value until it determines that a new record is being created. There is no way for Filemaker to "know" that a new record needs to be created until you commit the portal's record.
Is there some problem that this Filemaker feature is creating for you? There are ways to script things (especially in FMP 10) that would change this behavior.
Yes this is a problem for us since we need each portal row to have it's own unique id, but i assume that we can just always kip the first row and enter our first line on the second line in the portal.
I do have Filemaker 10 but our plant does not (they have 8) so I don't think that any tiggers work on their layouts and they are the ones who would be using this the most.
Do you have any other recommendations or should we just not use the first line?
You could create button and script to do the following:
Go To Portal Row [last]
Set Field [PortalTable::matchfield; LayoutTable::Matchfield]
Commit Record //may not be needed but use if if the layout doesn't automatically update to show the new portal record.
Go To Field[PortalTable::FieldwhereyouwantTheCursor]
Label that button "new portal row" or some such descriptive text.
Note: the above script may not function reliably if you have more than one portal on your layout. Add a Go To Field[portalTable::FieldINPortal] as your first line of the script if you have multiple portals.
Is the "match field" that you are referring to the fields that are related in the relationship between my portal and layout?
If so, then I followed your script correctly, but it did not fill in a serial number still. It works just as it did before.
Yes, that's what I meant by match field.
Here's a step by step description of a test file that I created. Check to see where it differs from your file as the method works for me.
I defined two tables: Parent, Child.
One number field, PrimaryKey, defined in Parent as an auto-entered serial number
Two number fields defined in Child:
ForeignKey, SerialNumber--defined to auto-enter a serial number
Parent:: PrimaryKey = Child::ForeignKey (Relationship defined to "Allow creation of records..." for Child table)
Placed a portal to Child on the Parent layout with just one field in it: SerialNumber.
Each time I ran the following script:
Go To Portal Row [Select; Last]
Set Field [Child::ForeignKey; Parent:: PrimaryKey]
I got a new record numbered with the next serial value in the field options for SerialNumber.
That's not how I have my realtionship set up. I'm probably wrong.
The portal is in realtion to a order.
Each order has it's own order number and i wanted the in row in the portal to have it's own line item number.
So i have my parent table with it's order number, relating to a child portal table via this order number.
Then on the child portal table, i have a line number serial field. So then each portal is related to a certain order with multiple line item numbers.
Did I set this up wrong?
That's exactly how I set up this sample file.
Parent:: PrimaryKey = OrderNumber in orders table
Child:: ForeignKey = OrderNumber in Line Item table
Child::SerialNumber = LineItem number.
If you want each set of line item records to start with one, you'll need a different auto-enter setting (a calculation) and a relationship, for your Serial Number field or just put @@ in the portal row if you only need it for display purposes.
The technique, however, still works though I had to include a Commit Record step to get the numbering to be consistant