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?


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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.