{"title":"Text.InsStr(Text, Text, Integer) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-insstr-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-insstr-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-insstr-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":"Inserts a substring into a string.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Text.InsStr(Text, Text, Integer) Method","slug":"textinsstrtext-text-integer-method","at":0,"chars":1943},{"level":2,"title":"Syntax","slug":"syntax","at":137,"chars":172},{"level":2,"title":"Parameters","slug":"parameters","at":309,"chars":411},{"level":2,"title":"Return Value","slug":"return-value","at":720,"chars":98},{"level":2,"title":"Remarks","slug":"remarks","at":818,"chars":273},{"level":2,"title":"Example","slug":"example","at":1091,"chars":720},{"level":2,"title":"Related information","slug":"related-information","at":1811,"chars":132}],"text":"# Text.InsStr(Text, Text, Integer) Method\n> Version: _Available or changed with runtime version 1.0._\nInserts a substring into a string.\n## Syntax\n```al\nNewString :=   Text.InsStr(String: Text, SubString: Text, Position: Integer)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nString\nType: text-data-type\nThe string into which you want to insert a substring.\nSubString\nType: text-data-type\nThe substring that you want to insert into String.\nPosition\nType: ../integer/integer-data-type\nSpecifies where to insert SubString. Position must be greater than or equal to 1. If Position is greater than the length of String, then the result is concatenated and copied to NewString.\n## Return Value\nNewString\nType: text-data-type\nThe input string including the specified substring\n## Remarks\nIf SubString is empty, then String is returned unchanged.\nIf Position is less than 1, an error is returned.\nIf Position is greater than the length of String, SubString is added at the end of String. For example, `InsStr(\"Thomas\",\"AAA\",999)` returns 'ThomasAAA'.\n## Example\n```al\nvar\n    Str: Text[60];\n    SubString: Text[60];\n    NewString: Text[60];\n    Text000: Label 'Press ENTER to continue.';\n    Text001: Label 'or ESC';\n    Text002: Label ' The test string before InsStr is called:>%1<';\n    Text003: Label ' The resulting string after InsStr is called:>%1<';\nbegin\n    Str := Text000;\n    SubString := Text001;\n    Message(Text002, Str);\n    NewString := InsStr(Str, SubString, 13);\n    Message(Text003, NewString);\nend;\n```\nThe first message window displays the following:\nThe test string before InsStr is called:\n>Press ENTER to continue.\\<\nThe second message window displays the following:\nThe resulting string after InsStr is called:\n>Press ENTER or ESC to continue.\\<\n## Related information\ntext-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}