I have been pulling some functions out of my View.mc file into a separate Utility.mc file. The code below works fine as a return statement of a function in the View.mc file but fails with the runtime error of cannot find symbol 'format' if it is moved to a separate Utils.mc file
return [format("$1$:$2$", [hour.format("%02d") , timeOfDay.min.format("%02d")]), ampm];
The only way I have found to resolve this error is to change the code above to:-
var string = "";
string = string.format("$1$:$2$", [hour.format("%02d") , timeOfDay.min.format("%02d")]);
return [string, ampm];
So I am guessing the problem resides with the first format. Why is the behavior different?
The method in the View.mc file is also within the View extends Ui.DataField class.