I am trying to create Officer Codes. To do this, I start with 3 letter characters and then add to it a number starting at “001”. For example, JDE001. Then if that Officer Code is already assigned in our system, I get the message “Officer already exists”.
If I receive this message, I need to increase the number by one (JDE002) and try to enter it again until the Officer Code is created.
I have tried to search for other users with similar issues to increase the number portion, but none of the examples are working.
Create variable counter with Default value 1
Create boolean variable OfficerExists
Do While (condition OfficerExists)
– Type Into (or however you’re entering the officer code) “JRE” + counter.ToString.PadLeft(3,"0"c)
– Check App State for Officer already exists
— In appears, set OfficerExists true; Assign counter = counter + 1
— In does not appear, set OfficerExists false
end Do While
I would also suggest setting a maximum value for the counter to avoid infinite loops in case of error. To do this just make the condition: