Skip to main content
rachelb16821056
Participant
January 18, 2018
Answered

How do I format this code so the date only updates once (when the file name is "Template") and doesn't update once the file name has changed?

I'm trying to piece together two bits of Javascript code that I found on these forums, but I'm not experienced in this at all so I keep getting an error message. This is what I have so far:

this.addScript("init", "var f = this.getField(\"Today\") + if (this.documentFileName=="Estimate Template.pdf")) f.value = new Date();");

What argument am I missing in this line of code?

Thanks in advance!

This topic is closed to new replies. Start a new post to keep the conversation going.
Thom Parker
Thom ParkerCorrect answer
Community Expert
January 18, 2018

Just put this code into a document script:

if (this.documentFileName=="Estimate Template.pdf")

     this.getField("Today").value = new Date();

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often

2 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 18, 2018

Just put this code into a document script:

if (this.documentFileName=="Estimate Template.pdf")

     this.getField("Today").value = new Date();

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
rachelb16821056
Participant
January 19, 2018

Many, many thanks.

Translate