These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Auto Date Field and Lockdown

elreaver
Registered: Dec 19 2011
Posts: 4

I have read several threads, but none that have successfully helped with my issue.
Using Adobe Adrobat 9 Pro 9.0
 
I have a form that I would like the date field to auto update with "Today" date when opened.
When the form is signed/saved I need this date field locked down so when it is opened a day/year later is shows the original date the form was opened and signed.
 
Right now, I have the following script to execute when document is opened:
var f = this.getField("Today");
f.value = util.printd("yyyy-mm-dd", new Date());
 
Works, but it still updates/changes date field - does not save the original saved/signed date.
 
Seems to be a common problem, yet several different solutions depending on the Adobe Version.
 
Thank you in advance for any assistance!

My Product Information:
Acrobat Pro 9.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
This can be a very tricky issue to resolve. If all users are using Acrobat, you can rewrite document level functions, so it could be possible to kill the script.

If there are users with Adobe Reader, you can not rewrite and scripts or code, so you need to control the updating the "Today" field to only occur when the field is blank, a status field indicates it can be updated, or a you can use the status property of the signature object.


George Kaiser

try67
Online
Expert
Registered: Oct 30 2008
Posts: 2398
All you need to do is add an if-condition to the code that checks if the signature field is filled or not. If not, update the date. If so, don't update it.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

elreaver
Registered: Dec 19 2011
Posts: 4
Thank you for the quick response.
I forgot to mention that I am creating the form in Pro, then extending the form for Reader.
I'll be distributing the form to users who only have Reader - fill out, sign, submit.
elreaver
Registered: Dec 19 2011
Posts: 4
try67 wrote:
All you need to do is add an if-condition to the code that checks if the signature field is filled or not. If not, update the date. If so, don't update it.
Thank you Sir,
How does this look?

var bAlreadyOpened;
function docOpened()
{
if(bAlreadyOpened != "true")
{
var f = this.getField("Today");
f.value = util.printd("yyyy-mm-dd", new Date());
bAlreadyOpened = "true";
}
else
{
}
}
docOpened();
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2398
No. You need to access the signature field and check if it's not empty. Something like this:

if (this.getField("Signature1").value!="") {
var f = this.getField("Today");
f.value = util.printd("yyyy-mm-dd", new Date());
}

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

elreaver
Registered: Dec 19 2011
Posts: 4
try67 wrote:
No. You need to access the signature field and check if it's not empty. Something like this:if (this.getField("Signature1").value!="") {
var f = this.getField("Today");
f.value = util.printd("yyyy-mm-dd", new Date());
}
Thanks, that does make sense. (forgive my rusty jscripting)
Now, would this belong in the page properties to open/execute on page open?
or
Does it belong in the Document Processing>Document Javascript?Not sure what the difference is between them, and since I'm extending to reader what location is appropriate.
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2398
It should be a doc-level script, not a page level script. After all, you don't want it to execute each time the user scrolls up and down from the first page, no?
In regards to Reader both options are the same.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com