Get Numeric Value from Previous Item

I’m trying to setup something where users can add steps. Step 1, Step 2, Step 3, etc.

I want to make it so that when someone adds a new step, it looks at the last step number added and then adds 1 to it so that my list stays ordered. Any idea on how I can get the last step number so that I can set this correctly?

The steps are stored as rows in a databse

Step Number Description
1 Desc. 1
2 Desc 2
3 Desc 3

New Step
4 Desc 4

In your example, do you mean how to get the number 3 (because step 3 is the last before the new step)?

If they are stored as rows in the database you can query the database for the steps sorted by “step number” descending. The first step of the list will be the one with the highest “step number” (if the assigned values are all correct).

I am just assigning a step number, so when I add a step, I give it 1, 2, 3 etc. This table has steps for multiple operations

If the data is saved as rows in a db table then you need to store the order of the data in a column, then query the db sorting the rows to get the last order number. If you store multiple operations in the same table you need to filter also by the operation type.

For example if you have
order, user, operation
1, user1, op1
2, user1, op1
1, user2, op1
1, user1, op2
2, user2, op1
2, user1, op2

to add a new op1 step for user1 you can query the db for all tge rows belonging to user1 that are op1, sorted by order descending. The first item will have order 2. Now you can create a new row 3, user1, op1.

Of course different kind of operations should belong to different table. This example is just for trying to help you as you said you have different operations in the same table.