{"title":"Text.StrSubstNo(Text [, Any,...]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-strsubstno-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-strsubstno-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-strsubstno-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Replaces %1, %2, %3...","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Text.StrSubstNo(Text [, Any,...]) Method","slug":"textstrsubstnotext-any-method","at":0,"chars":3825},{"level":2,"title":"Syntax","slug":"syntax","at":215,"chars":160},{"level":2,"title":"Parameters","slug":"parameters","at":375,"chars":235},{"level":2,"title":"Return Value","slug":"return-value","at":610,"chars":129},{"level":2,"title":"Remarks","slug":"remarks","at":739,"chars":2045},{"level":2,"title":"Example","slug":"example","at":2784,"chars":909},{"level":2,"title":"Related information","slug":"related-information","at":3693,"chars":132}],"text":"# Text.StrSubstNo(Text [, Any,...]) Method\n> Version: _Available or changed with runtime version 1.0._\nReplaces %1, %2, %3... and #1, #2, #3... fields in a string with the values you provide as optional parameters.\n## Syntax\n```al\nNewString :=   Text.StrSubstNo(String: Text [, Value1: Any,...])\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nString\nType: text-data-type\nA string containing '#' and/or '%' fields.\n*[Optional] Value1*\nType: ../any/any-data-type\nOne or more values (expressions) that you want to insert into String. You can specify up to 10 values.\n## Return Value\nNewString\nType: text-data-type\nReturns a new string with the provided values inserted into the specified string.\n## Remarks\nThis method replaces the numbered specifiers in a string with a string representation of the equivalent numbered value.\nThe specifiers in the string can be either %*n* or \\#\\#\\#\\#\\#\\#\\#*n*, where n represents a 1-based number. When you use the \\# specifier, the number can be anywhere in the specifier. For example, \\#\\#\\#2\\#\\#\\#\\# is allowed.\nThe %*n* specifier is replaced with the string representation of the value with their full lengths.\nThe \\#\\#*n* specifier is replaced with the same number of characters as the length of the specifier \\(including the number\\). The values are truncated to the length of the \\# field.\nIf the string representation is shorter than the length of the specifier, then it is left aligned.\nFor example, `StrSubstNo('Test %1 >#2##< >#3<', 1,2,3)` returns \"Test 1 >2   \\< >3 \\<\".\nIn this example, the following substitutions are made:\n %1 is replaced by '1' because a % field is replaced by the specified value in its full length.\n '\\#2\\#\\#' is replaced by '2 space space space' because the value is shorter than the field and therefore, the 2 is left aligned and the field is four characters long.\n \\#3 is replaced by '3 space' because the 3 is left aligned and the field is two characters long\n  If the string is longer, then asterisks are inserted to indicate overflow.\n  For example, `StrSubstNo('Test %1 >###2< >#3<', 'Thomas','Thomas',0)` returns \"Test Thomas >****\\< >0 \\<\".\n  In this example the following substitutions are made:\n %1 is replaced by 'Thomas' because a %1 field is replaced by the specified value in its full length.\n '\\#\\#\\#2' is replaced by '****' because the string 'Thomas' is longer than the \\#\\#\\#2 field. Each character in the field is replaced by an asterisk.\n \\#3 is replaced by '0 space' because the 0 is left aligned and the field is two characters long.\n  You can have several references to the same value.\n  For example, `StrSubstNo('Test %1 %3 %1', 555, 666, 777)` returns \"Test 555 777 555\".\n  If one of the values is null, then it is treated as an empty string.\n## Example\nThe following example shows how to use the StrSubstNo method.\n```al\nvar\n    Str: Text[1024];\n    AccountNo: Integer;\n    Balance: Decimal;\n    Text000: Label 'The balance of account %1 is $ %2';\n    Text001: Label 'The test string before StrSubstNo is called:\\\\%1';\n    Text002: Label 'The string after StrSubstNo is called:\\\\%1';\nbegin\n    Str := Text000;\n    AccountNo := 3452;\n    Balance := 2345 + 5462;\n    Message(Text001, Str);\n    Str := StrSubstNo(Str, AccountNo, Balance);\n    Message(Text002, Str);\nend;\n```\nThe first message window displays the following text:\nThe string before StrSubstNo has been called:\nThe balance of account %1 is $ %2\nThe second message window displays the following text:\nThe string after StrSubstNo has been called:\nThe balance of account 3452 is $ 7,807\n> NOTE\n> This example is run on a computer that has the regional format set to English \\(United States\\).\n## Related information\ntext-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}