Create an alternate key

Completed

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:

  1. Sign in to Power Apps and select Dataverse > Tables menu option in the left-hand navigation column.

  2. Select the table that you want to add a new key to.

  3. Select Keys from the options below Schema.

  4. Select + New key in the command bar.

  5. Give the key a display name.

  6. Select one or more columns that will make up the new key.

  7. 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.

Tip

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.