Search code examples
livecyclelivecycle-designer

Current date/time field not populating correctly in LiveCycle ES2


What I need the field to do is whenever the form is first opened, I need the field to be populated with the current time/date. If I add a "Date/Time Field", change the "Value" to "Calculated - Read Only" and change the "Data Format" in the "Binding" tab to "Date and Time", it doesn't show anything when I preview the PDF. Same goes for if I add a "Current Date" item and change the "Data Format" in the "Binding" tab to "Date and Time". Will the supplied objects not do this by default? DO I need to use a FormCalc or Javascript script to make it work? Any ideas?


Solution

  • I would put this in the docReady event of a field I want to populate the date automatically.

    var today = new Date();
    this.rawValue = parseInt(today.getMonth()+1)+"/"+today.getDate()+"/"+today.getFullYear();