I've created a script to aid me in the creation on account numbers for SAGE rather than me having them stored within the system.
It basically uses variables to create a search on an account number if its taken then increment the number then search again etc until a number that is searched is not found. This will then copy the account number and set it to the customer.
Around line 22 is when the increment is not actually incrementing on the next search. Its just searching the same account reference from earlier i.e.
STE02 instead of STE03, is something incorrect with the loop or how I'm using serial increment?
Ignore line 44-50 as this won't be doing anything