Using the New IncStr Overload in Business Central AL
With recent updates to AL language in Microsoft Dynamics 365 Business Central, developers now have more flexibility when working with strings containing numeric suffixes — thanks to the new overload of the IncStr method.
If you’ve ever had to increment a string with a number at the end (e.g., “INV001” to “INV002”), you’ve probably used IncStr. But until recently, IncStr only allowed an increment of +1.
Let’s explore how the new overload changes that.
🆕 What’s New in IncStr?
Traditionally, IncStr was used like this:
NewString := IncStr('INV001'); // Result: 'INV002'
Now, with the new overload, you can specify how much to increment by:
NewString := IncStr('INV001', 5); // Result: 'INV006'
✅ Syntax:
IncStr(Value: String, IncrementBy: Integer): String
This enhancement is particularly useful in scenarios like:
⚙️ Example
LastCode := IncStr(LastCode, 5); // Jump by 5 in one go
🚧 Cases to Consider
IncStr('ABC', 3); // Result: 'ABC3'
The new IncStr overload is a small change with big impact — making it easier to handle advanced string number incrementing without tedious code.
Stay Tuned for more.
For More visit https://ammolhsaallvi.blog/