How to Create a Primary Key for a Table in Dynamics AX2012

In node Table of AOT, i create new table and i want to set a primary key to a field ,which means that values of the field should be unique among the table values and want to make it auto-increment.

How can i do that.

Thank you.

Create a primary index, by using that field and make the field mandatory.

You need to handle it through code, by using a number sequence.

Keep the SurrogateKey as primary, unless you have a good reason to change it.

Create an index. Add a field / fields. Set the AllowDuplicate property to No to create an unique index.

SQL-style auto-increment is not used in Dynamics AX. If you just want a surrogate key, you already got one when you created a new table, so you don’t have to do anything. If you want an auto-incremented user-facing value, use a a number sequence.

Please consult the documentation to learn more information: Indexes and Keys [AX 2012]. Note that you can use a search engine to find the documentation you need.

  1. Create the Table and add required fields to the table as you all knows.
  2. Create an Index by dragging the required field to the Index.
  3. Set the following Index properties:
    a) AllowDuplicates to “no”.
    b) Alternate key to “yes”.
  4. Set the Primary Index property of the table to newly created index after creating the Index.

suppose u are having table student table , having field RollNumber ,rollnum u want as unique and incremental


| --------- studentName

|---------- RollNum

|---------- address

in the table ther is a node named as index ,Right click on it and say new index. Suppose I created new index with name Index1.

den on that newly created index drag the field roll num in it .

it will looks as :-



den set the property of Index1 as AllowDuplicate to “No” and alternate key to “Yes”.

the go into ur table property where u can see Primary kEY , bydefault its value is surrogate key ,in the drop down u can see ur index nem whch we nemed as Index1 select it.

and save ur table .

for incremental u should use num sequence

Thank you all

Could you please mark the reply/replies that answered your question? It will also show the whole thread as answered.