-
1. Re: Auto Fill Today's date into a PDF form
Gilad D (try67) Apr 30, 2014 6:40 AM (in response to OrthoVLo)You don't have direct access to the doc-level scripts in your version of Acrobat, but you can set do it via the console.
Run this code:this.addScript("init", "this.getField(\"Today\").value = new Date();");
Of course, you should have a text field in your file called "Today", set up as a Date field.
-
2. Re: Auto Fill Today's date into a PDF form
GKaiseril Apr 30, 2014 10:08 AM (in response to OrthoVLo)If one has the Standard version of Acrobat, you can use the "Open Page" action. And the code could be add to all pages. I would create an initialization function and docuement variable to see if the initialization function has been run.
function Initialize(cDateField) {
if(bInitialized == false || typeof bInitialized == "undefined") {
try{
this.getField(cDateField).value = new Date();
bInitialized = true;
}catch(e) {
bInitialized = false;
} finally {
return bInitialized;
} // end try;
} // end bInitialized false or undefined;
} // end Initialize function;
if(typeof bInitialized == "undefined") var bInitialized = false;
Initialize("MyDateField");
-
3. Re: Auto Fill Today's date into a PDF form
OrthoVLo Apr 30, 2014 11:22 AM (in response to Gilad D (try67))Can you tell me how to get to the console? I tried following the instructions in the knowledge base but when I go to set preferences, again, my screen doesn't look like the example shown. I'm obviously a novice.
Vanessa Lo, PA-C
Premier Orthopaedics & Sports Medicine
Centennial Medical Center
2400 Patterson Street Suite 300
Nashville, Tennessee 37203
615-342-6368
-
4. Re: Auto Fill Today's date into a PDF form
OrthoVLo Apr 30, 2014 11:24 AM (in response to Gilad D (try67))Neveremind. I figured it out. However, it puts the date in this format : Wed Apr 30 2014 13:23:37 GMT-0500 (Central Daylight Time)". How can I change it to just mm/dd/yyyy.
Thanks.
Vanessa Lo, PA-C
Premier Orthopaedics & Sports Medicine
Centennial Medical Center
2400 Patterson Street Suite 300
Nashville, Tennessee 37203
615-342-6368
-
5. Re: Auto Fill Today's date into a PDF form
OrthoVLo Apr 30, 2014 11:27 AM (in response to Gilad D (try67))Nevermind..figured out that too. Just changed the format settings in the text box. Thanks again and sorry for speaking too soon....twice.
Vanessa Lo, PA-C
Premier Orthopaedics & Sports Medicine
Centennial Medical Center
2400 Patterson Street Suite 300
Nashville, Tennessee 37203
615-342-6368
-
6. Re: Auto Fill Today's date into a PDF form
MFBMikey Jun 15, 2014 7:57 PM (in response to OrthoVLo)Hi Gilad
I found your script above very useful to autopopulate a field with todays date.
this.addScript("init", "this.getField(\"Today\").value = new Date();");
I wonder if it is possible to lock it after the form has been opened so it doesn't update or change automatically. For example if I have a field with todays date in it using the script above. If I open the form tomorrow the same field would have tomorrow's date. Is there a way of keeping the field to todays date even though the form may be opened again in the future?
Regards,
Michael
-
7. Re: Auto Fill Today's date into a PDF form
MFBMikey Jun 15, 2014 8:45 PM (in response to Gilad D (try67))Hi Gilad
I found your script above very useful to autopopulate a field with todays date.
this.addScript("init", "this.getField(\"Today\").value = new Date();");
I wonder if it is possible to lock it after the form has been opened so it doesn't update or change automatically. For example if I have a field with todays date in it using the script above. If I open the form tomorrow the same field would have tomorrow's date. Is there a way of keeping the field to todays date even though the form may be opened again in the future?
Regards,
Michael
-
8. Re: Auto Fill Today's date into a PDF form
Gilad D (try67) Jun 17, 2014 3:33 PM (in response to MFBMikey)Sure. Just change the code to:
this.addScript("init", "var f = this.getField(\"Today\"); if (f.value==\"\") f.value = new Date();");
You will need to completely reset the form if you want to update the field's value using this code.
-
9. Re: Auto Fill Today's date into a PDF form
MFBMikey Jun 21, 2014 7:01 AM (in response to Gilad D (try67))Thanks Gilad, works perfectly!!
-
10. Re: Auto Fill Today's date into a PDF form
jessejames1of3 Aug 22, 2014 12:30 PM (in response to Gilad D (try67))Will this also work if some one uses the form on another computer?
-
11. Re: Auto Fill Today's date into a PDF form
Gilad D (try67) Aug 22, 2014 12:32 PM (in response to jessejames1of3)Yes, if they use an application that supports JS, of course.
-
12. Re: Auto Fill Today's date into a PDF form
GKaiseril Aug 22, 2014 1:17 PM (in response to MFBMikey)You need to add some additional code to only fill-in the value of the field if it is equal to a null string or is empty.
function Initialize(cDateField) {
if(bInitialized == false || typeof bInitialized == "undefined") {
try{
// process only and empty field;
if(this.getField(cDateField).value == "") {
this.getField(cDateField).value = new Date();
bInitialized = true;
} // end empty field;
}catch(e) {
bInitialized = false;
} finally {
return bInitialized;
} // end try;
} // end bInitialized false or undefined;
} // end Initialize function;
if(typeof bInitialized == "undefined") var bInitialized = false;
Initialize("MyDateField");
Now you will need to figure out how to distribute the form so the date field will fill-in when the form is empty.
-
13. Re: Auto Fill Today's date into a PDF form
jessejames1of3 Aug 22, 2014 4:13 PM (in response to Gilad D (try67))Another question If I may.
What is the best to:
Fill in another field with with data If a certain value is select from a drop down sections list?
Example:
Select from Drop Down = "Mt. Vernon - 42"
Field to fill is "Store Location" which would fill with "4545 Burlington blvd, Mt. Vernon, WA 981212" based on the drop down selection above.
-
14. Re: Re: Auto Fill Today's date into a PDF form
Gilad D (try67) Aug 23, 2014 2:25 AM (in response to jessejames1of3)You can use something like this as the text field's custom calculation script:
var v = this.getField("Drop down field name").value; if (v=="Mt. Vernon - 42") event.value = "4545 Burlington blvd, Mt. Vernon, WA 981212"; else if (v=="Something else") event.value = "Another address"; // etc. else event.value = ""; -
15. Re: Auto Fill Today's date into a PDF form
jessejames1of3 Aug 24, 2014 8:09 PM (in response to Gilad D (try67))Thank you this helped so much
-
16. Re: Auto Fill Today's date into a PDF form
jessejames1of3 Aug 25, 2014 1:44 AM (in response to jessejames1of3)Any great advice on configuring the Custom created Submit button to save to the following:
\\data\AP Monitored Folder
with the file name that = Field "PO Number" and "CurrentDateTime"
-
17. Re: Auto Fill Today's date into a PDF form
Gilad D (try67) Aug 25, 2014 1:51 AM (in response to jessejames1of3)That can only be done using a script that is installed on the local machine of each user who is going to use this file.
-
18. Re: Auto Fill Today's date into a PDF form
jessejames1of3 Oct 13, 2014 9:36 AM (in response to Gilad D (try67))A couple question if I may,
* What would your suggestion be for a fill-able text field that references a list of 300-400 Vendor Names? I wouldn't want if to be a big drop down list, but some thing that would populate as it was typed as an option.
* I want to know the best route for Putting my document on my server for network access via web browser so that it can be filled out as it was built and then saved when a submit button was hit, but it would net to accessed by multiple users at the same time?
Your suggestions and are greatly appreciated and continue to expand my knowledge.
Please let me know your thoughts.
Thank You



