Using the New IncStr Overload in Business Central AL

Amol SalviBusiness Central3 days ago85 Views

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:

  • Batch processing: Skipping ranges (e.g., test IDs, invoice numbers)
  • Custom logic: Implementing non-sequential numbering patterns
  • Looping identifiers: Where the next string isn’t always +1

⚙ Example

LastCode := IncStr(LastCode, 5); // Jump by 5 in one go

🚧 Cases to Consider

  • It only increments the last numeric section of the string.
  • It respects the original number of digits (e.g., padding).
  • If there’s no number, it defaults to 1 and appends it.
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.

Original Post https://ammolhsaallvi.blog/2025/04/10/using-the-new-incstr-overload-in-business-central-al/

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
April 2025
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30     
« Mar   May »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...