Q:

REST - How to get the maximum of a number

A list has an int field named AccountNumber. Everytime a new record is created through the NewForm.aspx I need to fill out the field AccountNumber with max (AccountNumber for existing items) + 1.
I need to do it using javascript + jquery. How can I do that?

A:

You can use $orderby and desc to sort the items based on descending value of Account No. You can also use $top to return top n items. $select would be used for returning the field you want.
Eg: /_api/web/lists/getByTitle('List')/items?$orderby=AccountNo desc&$top=1&$select=AccountNo
You can then add 1 to the returned AccountNo.

