+ Start a Discussion

How to create unique key based on 2 fields

Greeting everyone,
I am an Access developer working on my first Salesforce project, and there are some things that I keep on banging my head against.
I created a custom TestData object to store student test data.  For each student there should only be one entry per year.
The object has both a StudentID and a Year field, but how can I ensure that the combination of them is unique?  It seems I can only select the 'unique' attribute on single fields, and when I create a custom formula field to concatenate those two fields, salesforce no longer presents the 'unique' checkbox on that formula-field.
Can someone please help me to make this simple thing work?
Hello MartinC,

The only way to validate on multiple fields will be through Apex. There is a sample within the Cookbook that may get you on the way to this but you will have to know some coding.