There is a nice validation called 'Reference source table has possible double look-up values’. It even tells us the solution to resolve it: 'Create a unique index on the source table of the reference, to ensure the look-up value is always unique. The unique index should have the following fields:
- All primary key columns which are also a foreign key column.
- The lookup display column.’
Why can't the Software Factory create these indexes automatically? It would save developers a lot of time and would improve the quality of the data quite a bit.
For us, a unique index on these columns isn’t always the answer. Often we create a new calculated column to use for the lookup. In very specific situations we even accept that the lookup might have double values. The validation forces us to think about the best solution.
Automatically adding the unique constraints could lead to some unexpected changes. The idea could still work but I’d like to be notified/warned when a unique constraint is automatically added and I’d like to be able to change/remove it if needed.
I agree with your comment,@J. de Lange . It should definitely based on a setting per lookup. The default behaviour should be true (maybe a project setting). For existing projects however, this setting should definitely be turned off and make it a developers decision if it is to be turned on.
Too bad I can't edit my comment, so here we go…
Your situation, using a calculated column as a lookup could be resolved/work in the same way. Try this example:
Hi Robert Jan,
There are reasons for developers to approve this validation. For instance if the column isn't used for any lookup field but only shown in the breadcrumb. The automatic creation of an Unique index would then be unnecessary. It would also be counter-productive if later the display/lookup column gets changed - then an new index would be created and so on.
What we certainly can do is expand a bit in the Validation Solution field to explain that the validation can be approved if for instance the lookup column/display column is not used inside a lookup, and is only there to be shown in the breadcrumb. Introducing a project version setting for this is also not the way of solving this we think. Do you agree@Robert Jan de Nie ?
I got you one better! Why cant we specify per lookup (with a simple checkbox) if that lookup should be unique. If so, the SF will create an index for us. This would give you more control and you wont have to specify an index for each lookup that needs to be unique (most of them).