How to Increase or Decrease Number from String by using INCSTR Function in BC D365

Using INCSTR Function in BC D365:

(1) In this blog, we will get to know about the use of the INCSTR function in BC D365. It increases a positive number or decreases a negative number inside a string by one (1).

(2) Syntax of INCSTR:

NewString := INCSTR(String)

(3) Now let’s take an example and see the result as shown.

INCSTR Function Code in BC D365
  • Message 1 is: Output 1 is: Account no. 100 does not balance.
  • Message 2 is: Output 2 is: Account no. 4342 shows a total of $-551.
  • Message 3 is: Output 3 is: No Response pop up.
  • Message 4 is: Output 4 is: Your bank account shows total of $1.

Note: The example shows that if the string contains more than one number, only the last number is changed. Furthermore, positive numbers and zero are increased and negative numbers are decreased. Finally, if there are no numbers in the string, then an empty string is returned.

(4) Remarks from Microsoft, as shown.

  • If a String contains more than one number, then only the number closest to the end of the string is changed. For example, ‘A10B20’ is changed to ‘A10B21’ and ‘a12b12c’ to ‘a12b13c’.
  • If String contains a negative number, then it is decreased by one. For example, ‘-55’ is changed to ‘-56’.
  • Zero (0) is considered a positive number. Therefore, it is increased it by one. For example, ‘A0’ is changed to ‘A1’.
  • When String contains a number such as 99, it is increased to 100 and the length of the output string is: LEN(String) + 1. For example, ‘a12b99c’ is changed to ‘a12b100c’.
  • If the String does not contain any number, the output string is an empty string. For example, ‘aaa’ is changed to ”.
  • INCSTR only increments integer numbers within strings, not decimals. For example, if you call INCSTR on the string a99.99b then the result is a99.100b.

Process and Setup of Drop Shipment in Business Central D365
Reverse Sales Shipment in Business Central D365
How to Create Purchase Order in Business Central
Use of RUN and RUNMODAL in Business Central
Customize Post StrMenu or Dialog option at the time of Sales Posting in D365 BC
Text.IncStr(Text) Method– Microsoft Docs

Leave a Reply