Increment a string field that ends with a number by 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2023 07:14 PM
Hi,
We have a form automation that creates a new server. One of the requirements is to check to see if the server requested has already been created in our CMDB and if it already exist then check for the next available number.
Our servers have a naming convention like the following:
CYSQLSNT01
If a server already exist like the one above, then they want me to increment the last numbers of the name. So the next would be CYSQLSNT02 or CYSQLSNT03.
Based on the requirements, the last 2 characters of the server name will always be a 2 digit number.
How can I increment this number? ParseInt didn't work. It came us as NaN.
I also need to make sure that the numbers start with 0, if it is one number. For instance, if the number is 5 then it would be 05 or if the number is 16, then it would just be 16. The last 2 characters are 2 digit numbers.
Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 02:57 PM - edited 10-09-2023 03:03 PM
Hi @yoli1
I basically used the Do the following until flow action to loop through and check the CMDB to see if that server name already existed.
I looped through until the next number is available. I created an action just to get me the numeric value only. I start with 0 and it would use the Do the following loop to continuously check to see if that servername + increment number is taken.
This document can help you with understanding the Do the following until flow logic.