On 4/7/2012 1:50 AM, Christoph Kaufmann wrote:
> FMP 10: what's best practice to ensure a combination of two fields is
> unique?
>
> Here's what I did:
>
> Set up a third data field (text) with auto-enter calc Field1& "-"&
> Field2 and ask set valdiation to unique.
>
> Seems to be working, but maybe I'm looking to far. Better ways?
>
> What didn't work:
>
> Setting up an auto relation based on the two fields and put and count
> the related records in the validation of one of the fields (must be
> lower than 2). Doesn't work because the count shows 2 after commit, and
> validation checks before commit. Can't ask for less than 1 related
> record because this prevents any change.
I would go with your technique of an added relationship to base your
calc'd validation. Base your validation, however, on THREE fields: the
two whose combination must be unique, PLUS the third based on the unique
primary key fields NOT being equal. That way, you need only test for
the count being >0 (or better, avoid the count by just testing that the
related key field isempty).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg
(818) 883-2846
FM Professional Solutions, Inc. Los Angeles
FileMaker Certified Developer
Associate Member, FileMaker Business Alliance