{"title":"Text.Substring(Integer [, Integer]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-substring-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-substring-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-substring-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":"Retrieves a substring from this instance.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Text.Substring(Integer [, Integer]) Method","slug":"textsubstringinteger-integer-method","at":0,"chars":1428},{"level":2,"title":"Syntax","slug":"syntax","at":147,"chars":165},{"level":2,"title":"Parameters","slug":"parameters","at":312,"chars":303},{"level":2,"title":"Return Value","slug":"return-value","at":615,"chars":91},{"level":2,"title":"Remarks","slug":"remarks","at":706,"chars":590},{"level":2,"title":"Related information","slug":"related-information","at":1296,"chars":132}],"text":"# Text.Substring(Integer [, Integer]) Method\n> Version: _Available or changed with runtime version 1.0._\nRetrieves a substring from this instance.\n## Syntax\n```al\nSubstring :=   Text.Substring(StartIndex: Integer [, Count: Integer])\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nText\nType: text-data-type\nAn instance of the text-data-type data type.\nStartIndex\nType: ../integer/integer-data-type\nThe one-based starting character position of a substring in this instance.\n*[Optional] Count*\nType: ../integer/integer-data-type\nThe number of characters in the substring.\n## Return Value\nSubstring\nType: text-data-type\nThe substring extracted from this instance.\n## Remarks\nStarting with Business Central application version 27.1, the platform supports a Count parameter that exceeds the length of the input text. In application version 27.0 and earlier, the following code raises a runtime error Index and length must refer to a location within the string. (Parameter 'length'):\n```al\nNewString := '12345'.Substring(1, 10);\n```\nIn this example, the input text `'12345'` has a length of 5, but the Count value is 10, which exceeds the string length. If you're targeting application version 27.0 or earlier, use text-copystr-method instead of Substring.\n## Related information\ntext-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}