web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Can we add a string variable to have an increment using x++?

(0) ShareShare
ReportReport
Posted on by 552
Hello guys,
 
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.
 
Thanks.
I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    300,911 Super User 2025 Season 2 on at
    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.
  • Suggested answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at
    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.
  • Ken Manhattan Profile Picture
    552 on at
    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
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    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.
  • Ken Manhattan Profile Picture
    552 on at
    Hi Bharani,
     
    and your suggestion is ?
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    300,911 Super User 2025 Season 2 on at
    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
  • Verified answer
    Arunraj Rajasekar Profile Picture
    1,743 on at
     
    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.
    1. Read the string value in a buffer, something like this 
      str testStr = TEST-0002;
    2. Use substring to get the number and convert it to number
      int incNum = str2int(subStr(testStr,5,99);
    3. Then increment the number 
      incNum = incNum +1;
    4. convert the number again to string, concatenate it back and save it.
     

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans