{"title":"Text.ConvertStr(Text, Text, Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-convertstr-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-convertstr-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-convertstr-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 all chars in source found in FromCharacters with the corresponding char in ToCharacters and returns the converted string.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":486,"chars":182},{"level":2,"title":"Parameters","slug":"parameters","at":668,"chars":326},{"level":2,"title":"Return Value","slug":"return-value","at":994,"chars":95},{"level":2,"title":"Remarks","slug":"remarks","at":1089,"chars":334},{"level":2,"title":"Example","slug":"example","at":1423,"chars":772},{"level":2,"title":"Related information","slug":"related-information","at":2195,"chars":132}],"text":"> Version: _Available or changed with runtime version 1.0._\nReplaces all chars in source found in FromCharacters with the corresponding char in ToCharacters and returns the converted string. If the length of the FromCharacters parameter and the ToChars parameter are different, an exception is thrown. If the parameter FromCharacters or the parameter ToChars is empty, the source is returned unmodified. Each element in source is only converted ONCE a double-replacement cannot happen.\n## Syntax\n```al\nNewString :=   Text.ConvertStr(String: Text, FromCharacters: Text, ToCharacters: Text)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nString\nType: text-data-type\nThe string that you want to convert.\nFromCharacters\nType: text-data-type\nThe characters that you want to replace. This function is case-sensitive.\nToCharacters\nType: text-data-type\nThe new characters with which you want to replace the FromCharacters. This function is case-sensitive.\n## Return Value\nNewString\nType: text-data-type\nThe input string with the converted characters.\n## Remarks\nThe characters in the FromCharacters parameter are replaced by the characters in the ToCharacters parameter.\nIf the lengths of the FromCharacters and ToCharacters strings are not equal, then a run-time error occurs.\nIf either the FromCharacters or the ToCharacters strings are empty, then the source is returned unchanged.\n## Example\n```al\nvar\n    OriginalString: Text[30];\n    FromChars: Text[30];\n    ToChars: Text[30];\n    NewString: Text[30];\n    Text000: Label 'Do you want to leave without saving?';\n    Text001: Label 'lws';\n    Text002: Label 'LWS';\n    Text003: Label 'The original sentence is\\\\: %1';\n    Text004: Label 'The sentence is converted to:\\\\ %1';\nbegin\n    OriginalString := Text000;\n    FromChars := Text001;\n    ToChars := Text002;\n    NewString := ConvertStr(OriginalString, FromChars, ToChars);\n    Message(Text003, OriginalString);\n    Message(Text004, NewString);\nend;\n```\nThe first message window shows:\nThe original sentence is:\nDo you want to leave without saving?\nThe second message window shows:\nThe sentence is converted to:\nDo you Want to Leave Without Saving?\n## Related information\ntext-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}