For few days I've been trying to include the actual Moment.js library in my dynamic PDF which I've created with Adobe Livecycle Designer.
We've used an older version (1.7.2) without any problems but now I only get a 'Function not exist' error.
Does anyone have any expierience with this?
Thanks in advance.
How to include Moment.js in an Adobe LiveCycle Form:
- Download the minified script
- In LiveCycle Designer open your form and create a Script Object called MOMENTJSMIN
- Copy the minified script into that Script Object
- In the Script Editor window of LiveCycle Designer, edit MOMENTJSMIN Script Object in the following manner:
Remove all the script up to but not including the second curly brace { :
!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function()
Remove the rounded parenthesis and semicolon from the end of the minified script
Add this line to the beginning of the minified script:
if (xfa.momentjs == undefined) xfa.momentjs = function()
In the MOMENTJSMIN Script Object add this function after the end of the script:
function getMomentJS(){
return xfa.momentjs();
}
Now your MOMENTJSMIN script object is set up to provide Moment.js to scripts throughout your form.
To use Moment.js in any of your script, start your script object or event script with this line:
var moment = MOMENTJSMIN.getMomentJS();
Now you can use moment() anywhere in the script that starts with that line. eg:
var moment = MOMENTJSMIN.getMomentJS();
var jan07 = moment([2007, 0, 29]);
app.alert(moment().format("dddd, MMMM Do YYYY, h:mm:ss a"));
app.alert(jan07.format("dddd, MMMM Do YYYY") + " was " + jan07.fromNow());
app.alert(moment.isDate(new Date()));
What I would check first:
- Make sure your script is fully loaded before trying to invoke functions from it. (check the event, where you call the function-calculate, form:readty etc.)
- Check the script referencing. Right path? Right name?
- Check if the function really exists
- Check function parameters.