Need help on some logic, for example when I have a variable like /TEST-0001/, can we make a code to have it increase ?
So the end result, I will have an increase variable like /TEST-0002, TEST-0003, TEST-0004, and so on/. For how many increment, I add an input for user to specify how many they need.
FYI, for an odd reason, I can't use number sequence for this activity.
Can we add a string variable to have an increment using x++?
Hi,
I have explained the logic in four steps below. You can simplify and improve it as per your business requirement. Validate before saving the result to table to avoid duplicate records.
Read the string value in a buffer, something like this
str testStr = TEST-0002;
Use substring to get the number and convert it to number
int incNum = str2int(subStr(testStr,5,99);
Then increment the number
incNum = incNum +1;
convert the number again to string, concatenate it back and save it.
Can we add a string variable to have an increment using x++?
Hi Ken,
When you have a main project, you can specify a format that will be added to the main project when creating sub projects.
Assume you have project 1001 and a format set as -###. When creating subprojects for this project, it will create them while replacing the hash symbols with numeric values. E.g.
1001-001
1001-002
1001-003
etc.
A sub for another project will start at 1 again. It does not require setting up a number sequence.
You can find the logic in the method generateNextSubProjectId on the table ProjTable.
Can we add a string variable to have an increment using x++?
Yeah you can just increment the digit value and again concat it to the string. This doesn't require number sequence. But based on your requirement we can suggest how to increment.
Can we add a string variable to have an increment using x++?
Hi Andre,
I'm sorry, but what "subproject" you meaning ? And this is not handled by number sequence ? cause what I look is not the one using number sequence setup.
Thanks
Suggested answer
Martin Dráb230,379Most Valuable Professional
on at
Can we add a string variable to have an increment using x++?
I would parse the string to the number and the prefix, increased the number (++ operator) and composed the string again.
Increasing a character code is technically possible, but it's not what you want. For example, in ASCII, the next character after '9' is ':'. It can't be '10', because that's a string consisting of two characters, not a character, therefore it's a completely different thing.
Can we add a string variable to have an increment using x++?
Hi Ken,
Yes this is possible. I'm not able to directly paste an example, but you can find one yourself in the application. When creating sub-projects, a string gets incremented. You can do some reverse engineering to find out this is done in the standard.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.