Autoincrement in string values

0
Hi, I need the attribute to save a string kind of values like EMP_01, EMP_02, EMP_03 and so on. How this functionality can be implemented in mendix ?
asked
2 answers
3

If your string value is always built up the same way, you can use String Functions to separate the number from the rest of the string and increment it. So for instance, in your example, you could find the location of the underscore with the “find()” function, then use a “substring()” to separate out the number. You can then convert it to an int, increment it by one, add the 0 in front if necessary and make it into a string, and then change your original attribute to be ‘EMP_’  + the new string.

Alternatively you could add an extra attribute to keep track of the number and simply build up your EMP_ value based on that number. This would be the preferable option in my eyes, as it's way less prone to error. The only downside is you have another attribute in your database.

answered
0

Thanks for answer, it helped me.

answered