{"title":"BigText.GetSubText(var Text, Integer [, Integer]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/bigtext/bigtext-getsubtext-text-integer-integer-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/bigtext/bigtext-getsubtext-text-integer-integer-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/bigtext/bigtext-getsubtext-text-integer-integer-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":"Gets part of a BigText variable.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"BigText.GetSubText(var Text, Integer [, Integer]) Method","slug":"bigtextgetsubtextvar-text-integer-integer-method","at":0,"chars":4224},{"level":2,"title":"Syntax","slug":"syntax","at":152,"chars":112},{"level":2,"title":"Parameters","slug":"parameters","at":264,"chars":1297},{"level":2,"title":"Return Value","slug":"return-value","at":1561,"chars":102},{"level":2,"title":"Remarks","slug":"remarks","at":1663,"chars":241},{"level":2,"title":"Example 1","slug":"example-1","at":1904,"chars":691},{"level":2,"title":"Example 2","slug":"example-2","at":2595,"chars":307},{"level":2,"title":"Example 3","slug":"example-3","at":2902,"chars":319},{"level":2,"title":"Example 4","slug":"example-4","at":3221,"chars":378},{"level":2,"title":"Example 5","slug":"example-5","at":3599,"chars":490},{"level":2,"title":"Related information","slug":"related-information","at":4089,"chars":135}],"text":"# BigText.GetSubText(var Text, Integer [, Integer]) Method\n> Version: _Available or changed with runtime version 1.0._\nGets part of a BigText variable.\n## Syntax\n```al\n[Length := ]  BigText.GetSubText(var Variable: Text, Position: Integer [, Length: Integer])\n```\n## Parameters\nBigText\nType: bigtext-data-type\nAn instance of the bigtext-data-type data type.\nVariable\nType: ../text/text-data-type\nThe sub text of the BigText that is retrieved. This is the actual text that is returned.\nPosition\nType: ../integer/integer-data-type\nThe position in the BigText variable that the sub text is to be retrieved from. If this parameter is less than one, then a run-time error occurs. If this parameter is greater than the length of the BigText variable, then an empty string is returned. If the value of this parameter plus the value of the Length parameter is greater than the length of the BigText variable, then the remainder of the BigText variable from the position specified by this parameter is returned.\n*[Optional] Length*\nType: ../integer/integer-data-type\nThe length of the sub text that should be retrieved. This parameter is optional. If this parameter is omitted the function retrieves a sub text that starts at Position and runs to the end of the BigText variable. If this parameter is less than 0, then a run-time error occurs. If the value of the Position parameter plus the value of this parameter is greater than the length of the BigText variable, then the remainder of the BigText variable from the position specified by this parameter is returned.\n## Return Value\n*[Optional] Length*\nType: ../integer/integer-data-type\nThe length of the result text.\n## Remarks\nThe first character in a BigText variable is position 1.\nTo delete the content in a BigText variable use the ../system/system-clear-joker-method. The following code snippet shows the syntax for the clear method. `Clear(BigText)`.\n## Example 1\nThe following examples demonstrate how to use the GetSubText method. This example requires that you create the following global variables and text constant.\n```al\nvar\n    MyBigText: BigText;\n    VarSubText: Text;\n    Text000: Label 'VarSubText = %1';\n```\nThe following example initializes the content of the MyBigText variable with the text ABCDEFG. The method starts from the third position \\(the character C\\) in the MyBigText variable and retrieves two characters. The result is the subtext CD. This is because the number 2 is specified for Length .\n```al\nMyBigText.AddText('ABCDEFG');\nMyBigText.GetSubText(VarSubText, 3, 2); // Returns CD.\nMessage(Text000, VarSubText);\n```\n## Example 2\nThe following example initializes the content of the MyBigText variable with the text ABCDEFG. The method returns an error because zero is specified for Position.\n```al\nMyBigText.AddText('ABCDEFG');\nMyBigText.GetSubText(VarSubText, 0, 4); // Returns an error.\nMessage(Text000, VarSubText);\n```\n## Example 3\nThe following example initializes the content of the MyBigText variable with the text ABCDEFG. The method returns an error because a negative number is specified for Length.\n```al\nMyBigText.AddText('ABCDEFG');\nMyBigText.GetSubText(VarSubText, 5, -2); // Returns an error.\nMessage(Text000, VarSubText);\n```\n## Example 4\nThe following example initializes the content of the MyBigText variable with the text ABCDEFG. The method returns an empty string because the number specified for position is greater than the length of the MyBigText variable.\n```al\nMyBigText.AddText('ABCDEFG');\nMyBigText.GetSubText(VarSubText, 15, 4); // Returns an empty string.\nMessage(Text000, VarSubText);\n```\n## Example 5\nThe following example initializes the content of the MyBigText variable with the text ABCDEFG. The method starts from the forth position \\(the character D\\) and retrieves all the characters in the MyBigText string. The result is the subtext DEFG. This is because the number specified for Length is greater than the length of the MyBigText variable.\n```al\nMyBigText.AddText('ABCDEFG');\nMyBigText.GetSubText(VarSubText, 4, 15); // Returns DEFG.\nMessage(Text000, VarSubText);\n```\n## Related information\nbigtext-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}