Auto increment in 2 lines of self supporting code.

Auto increment in 2 lines of self supporting code.

As long as you have 1 record with a number field that has a number in it, then these 2 lines of code will work:

LastRecord  =  Magnet_Board_Form  [ID != 0] sort by  OrderID desc range from 1 to 1;
input.OrderID = (LastRecord.OrderID  +  1);

So how does it work?
The first line is a "fetch" it sorts all records in form "Magnet_Board_Form" by the field "OrderID" in descending order, then grabs just the top record and calls it "LastRecord"
The second line then increments the "OrderID" field of the "LastRecord" variable by one and assigns the field to "OrderID" on the current record.

Notes:I have this set on OnLoad, but it could be set OnSuccess or OnUpdate to avoid complications of two people entering an order at the same time.

So there. You now have an Auto Increment field.