While using the substring String function in the microflow expression I get a strange (not immediately understandable) error if the string is shorter than the length of required substring. E.g.: if I do substring($a, 0, 100) and the $a length is just 90, then it will give an error about the whole expression. But why? A 100-length substring of the 90-length string is still just the same string, isn’t it? What do I miss here?
If you think of the contents of a string as an array of single character strings, this result makes a bit more sense. When calling Substring, Mendix tries to get the contents of the array in positions 0-99, however, if there are no values in some of the array positions, an error results. The way around this that I’ve used is:
if length($a) > 100