FileMaker - Finding Primary Key of First Related Record
I'm using a script to create a new Invoice
record. I'd like to automatically set the invoice's fClient fContactID column to the ID of the client's first contact.
In my script, how would I find/compute the ID of the cl开发者_StackOverflowient's first contact? SetField with a calculated result of Min(Contact_Invoice Contact::ContactID)
didn't work.
Tables:
Client
- primary key: ClientID
Contact
- has foreign key: fClientID (a client can have many contacts)
Invoice
- has foreign keys: fClientID & fContactID (an invoice is associated with one client and with one of that client's contacts)
Thank you,
BenYou say you want to set the "fClientID", but from your description it sound more like you're wanting to set the fContactID. Is that right?
If that's the case, then you have an Invoice, related to a Client, which is directly related to a Contact. What you're doing is right, but if it's not working then your context isn't right. Your context at the time is the Invoice table, so the related Contact needs to be accessible from there.
You could also use an auto enter calc instead of a script to set this. Extra bonus is that this will only let you select a valid context and related table.
精彩评论