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?

Jan 18, 2018

Copy link to clipboard

Copied

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!

Just put this code into a document script:

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

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

TOPICS
Acrobat SDK and JavaScript

Views

99

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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?

Jan 18, 2018

Copy link to clipboard

Copied

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!

Just put this code into a document script:

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

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

TOPICS
Acrobat SDK and JavaScript

Views

100

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 18, 2018 0
Jan 18, 2018

Copy link to clipboard

Copied

Just put this code into a document script:

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

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 18, 2018 0
Jan 19, 2018

Copy link to clipboard

Copied

Many, many thanks.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 19, 2018 0