Importing moment.js in to a Code Task | XM Community
Skip to main content

We have been using moment.js to format dates imported via Salesforce outbound message connections. This works well in a survey where we can include the script src in the header of the survey and then add a Javascript block at the top of our survey. However, when we need a formatted date in a survey invitation email we usually will push the formatting responsibility back in to Salesforce where we have a formula field handle the work. The resulting string is then imported and used as a merge field in the email.
Now we have Code Tasks which at first glance appear to be a great tool for formatting Salesforce imported data for use in our survey invitation emails. The question is can we import moment.js ? Is there a way to do this or is a similar feature available already in the implementation of node.js that supports the Code Tasks?

I haven't tried it, but the documentation says that we can't make external calls in Code Tasks.
They'll expose some variables, but that's all.
You could try copying the relevant functions from the library, but check its license before doing that.


Leave a Reply