Using UIHelper.momentHelper returns error when used in Type method


I’m trying to use UIHelper within a function on a Type to pre-populate some things for UI conditionally based on calc fields. However the following returns an error in static/console and also when my method is invoked:

UIHelper.momentHelper(new Date(), 'MM/DD/YYYY h:mm a')
Uncaught ReferenceError: moment is not defined
    at Object.momentHelper

I’m assuming it doesn’t have access to Moment.js? Is this error intentional or expected? When run from console on a UI page, it returns correctly. Is there a similar type/function I can use server side that would accomplish the same thing?

Conditionally Refer to Other Fields in One Column in KendoGrid

That error is expected. All the methods on UIHelper are js client, and this method in particular requires a 3rd party library (moment.js) that is not available in the C3 Console, but only as part of a C3 UI Framework-based client-side application. JavaScript runtimes, until very recently, were restricted to server and client, when in reality there are multiple types of client-side runtimes. Going forward, the runtime requirement for these methods will be clarified as we will declare a specific JavaScript runtime for C3 UI Framework-based applications.


Ok I figured so.

So the reason I’m trying to leverage this is because I’m prebuilding some html responses in calc fields per:

What would be the best method to get this sort of functionality?


To achieve this functionality server-side, I recommend doing:"MM/dd/yyyy h:mm");

Not sure how to format the AM/PM though.
But as an aside, be careful about forcing a specific date format that is not locale-aware.