Search code examples
microsoft-dynamicsnavision

Increment Number OnInsert()


I am trying to increase a field number whenever a new row is added to my table. First I created a variable lastItem specified as a Record with Subtype to my Table. Now I created the following Code on the OnInsert() trigger:

lastItem.FINDLAST;
ItemNo := lastItem.ItemNo + 10;

The above code seems not to work on the OnInsert() trigger but works for one row when I enter it on the ItemNo - OnValidate() trigger.

Any ideas how to get an increasing Number on every new row in my table?


Solution

  • Are you sure that's Dynamics CRM? The code is a Dynamics NAV C/AL code and you talking about the Item table? In this case let NAV to give you the next number from the No. Series properly. You can use the same approach in any other table : related pattern