Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Defining unique fields

Featured Replies

Hello.

I'm defining a new file and I would like to have two fiels as identifiers (unique fields) for that file. How is that possible. I don't want them to be unique separetely, but that their association is unique. I need your help. I'm thinking about some calculated verification, bit it really looks like a "trick". Is there some other ways ?

Thanks.

Hi Benoit ...

Without knowing in which order data is entered, or whether a field is allowed to remain empty, I think this should cover all of the possibilities:

1. Create a calculated key field:

"c_key" = fieldA & "_" fieldB

2. Create a self relationship of c_key to c_key. Call it "self c_key"

3. Create a constant calculation, i.e., a calculation field with the number 1 entered into the calc definition window. Call it "constant".

4. In the Validation windows for fieldA and fieldB, select the "Validated by calculation" option, and enter the following calculation:

Case(not IsEmpty(fieldA) and not IsEmpty(fieldB) and not IsEmpty(self c_key::constant), 0, 1)

This will allow two records to contain the same value in, say, fieldA, while fieldB remains empty. The validation will only be enforced when both fields contain data, and will not allow the same data in fieldA and fieldB in more than 1 record.

You might want to select the "Strict: do not allow user to override validation", and also enter a custom message for the user if the test for uniqueness fails.

Try something like this:

Create a calculation field that concatonates the two values:

FieldsAB = FieldA & "_" & FieldB

Make a self joining relationship, using FieldsAB:

SelfJoin - FieldsAB ???:= FieldsAB

Make sure each record has a unique identifier apart from the double-ID you want to use:

ID - Auto-enter Serial Number

Now, for fieldA and fieldB, make this the validation:

Count(SelfJoin::ID) = 0 or (Count(SelfJoin::ID)=1 and SelfJoin::ID = ID)

This should do the following:

If no record exists with the same fieldAB value, then count(SelfJoin::ID) will equal 0 and the test will pass.

If a record DOES exist with the same fieldAB value, make sure it's the current record (this is in case you want to change an existing value).

I only did a quick test of this, so there may be situtations where it wouldn't work. But I can't think of any offhand.

Jeff

  • Author

Thanks a lot. This is a calculated verification. So it seems that it is not possible to do it through the definitions of the two fields themselves. I'll go for that. I just wanted to know if there were some ways to avoid the calculated verification. See you soon ;o)

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.