Create an alternate key
It's common to need a way to uniquely identify a record in a table. By default, Microsoft Dataverse tables have a GUID as their only unique column. This GUID is called the Primary Key and it consists of a long string of numbers and letters that aren't useful to a regular user regarding meaning or significance. So, you might want to define an alternate key to enhance lookups for your users.
Defining a new key for a table allows you to identify a record in a more meaningful way by using a column that is familiar to your users. When you define a column as a key, Dataverse ensures that every entry in that key column is required and unique, so you can use the key column to distinctively identify a specific record. It's especially helpful if you're integrating your data with an external system that uses an ID or number to identify a record (and not the Dataverse GUID). It also improves the search and filtering on the particular column because alternate key fields are always indexed.
Finally, keys can be based on a single column (Order ID) or a combination of fields, such as Financial year and Order ID. If you set a key on a column, and try to enter duplicate data, that record will fail to save.
You can easily define an alternate key for a table by using the Power Apps portal with the following steps:
Sign in to Power Apps and select Dataverse > Tables menu option in the left-hand navigation column.
Select the table that you want to add a new key to.
Select Keys from the options below Schema.
Select + New key in the command bar.
Give the key a display name.
Select one or more columns that will make up the new key.
Select the Save button.
It may take a few minutes for Dataverse to create the new key and indexes (depending on the size of your existing table). Then, you can start using it in your business solution.
If you have duplicated data in a column that is used by the key in multiple records, then the key will not be created. You can only create a key if the data in the column's existing record is unique across all records in the table.
Need help? See our troubleshooting guide or provide specific feedback by reporting an issue.