How to use moment.js in Service Portal

davilu
Mega Sage

I've read that there is moment.js out of the box in Service Portal.  I located the dependency called moment-timezone-with-data-2010-2020-v0.5 and tried to use it like this in an object array:

 

start_date: moment(onbCase.getDisplayValue('hr_profile.employment_start_date')).format('MMM d, YYYY'),

 

However, I keep getting an error saying Server JavaScript error "moment" is not defined.

How exactly are you supposed to use the ootb moment.js dependency in Service Portal?

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

Please check below video which mentions steps to consume moment.js

 

https://www.youtube.com/watch?v=JrVGodtzY3U&feature=youtu.be

 

Regards,

Sachin

Hey Sachin, that video didn't really help to show how to use it in Service Portal.  Do you have any suggestions on how to load the dependency and use it in widget code?