FileMaker - 查找第一个相关记录的主键
我正在使用脚本创建新的 Invoice
记录。我想自动将发票的 fClient fContactID 列设置为客户首次联系人的 ID。
在我的脚本中,如何查找/计算客户第一次联系的 ID?计算结果为 Min(Contact_Invoice Contact::ContactID)
的 SetField 不起作用。
表格:客户端
- 主键:ClientID联系人
- 有外键:fClientID(一个客户端可以有多个联系人)Invoice
- 有外键:fClientID & fContactID(发票与一位客户以及该客户的联系人之一相关联)
谢谢,
本
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 client's first contact? SetField with a calculated result of Min(Contact_Invoice Contact::ContactID)
didn't work.
Tables:Client
- primary key: ClientIDContact
- 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,
Ben
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您说您想设置“fClientID”,但从您的描述来看,听起来更像是您想设置fContactID。是这样吗?
如果是这种情况,那么您就有一张与客户相关的发票,该发票与联系人直接相关。你所做的事情是正确的,但如果不起作用,那么你的环境就不正确。您当时的上下文是发票表,因此需要从那里访问相关的联系人。
您还可以使用自动输入计算而不是脚本来设置它。额外的好处是,这只会让您选择有效的上下文和相关表。
You 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.