3
Add a ToText method to the Label datatype. This would allow it to then be used in chained functions with the dot operator. It would also then support meaningful replacement text as you would not be limited to %1 or #1.
This more modern construct would be similar to the way AL IndexOf is a replacement for the old C/AL StrPos.
Old Code
MyLabel: Label 'Label text %1';
TextVariable := StrSubstNo(MyLabel, ReplacementValue);
Proposed Code
MyLabel: Label 'Label text ';
// Once the label has been converted to a Text then it can be chained using the dot operator.
TextVariable := MyLabel.ToString().Replace('', ReplacementValue).Trim().ToLower(), etc.;
This more modern construct would be similar to the way AL IndexOf is a replacement for the old C/AL StrPos.
Old Code
MyLabel: Label 'Label text %1';
TextVariable := StrSubstNo(MyLabel, ReplacementValue);
Proposed Code
MyLabel: Label 'Label text ';
// Once the label has been converted to a Text then it can be chained using the dot operator.
TextVariable := MyLabel.ToString().Replace('', ReplacementValue).Trim().ToLower(), etc.;
STATUS DETAILS
Needs Votes
Comments
Sorry, this should probably be ToText instead of ToString since the TextBuilder class uses ToText.
TextVariable := MyLabel.ToText().Replace('MatchText', 'ReplacementValue').Trim().ToLower(), etc.;
Category: Development
Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.
Best regards,
Business Central Team