Print Page | Close Window

Unique ID

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
Printed Date: 29 Mar 2020 at 11:11pm
Software Version: Web Wiz Forums 11.10 -

Topic: Unique ID
Posted By: jhinckley
Subject: Unique ID
Date Posted: 29 Dec 2011 at 9:24pm
I came across the code shown at the bottom of the post, and it does pretty much what I want but not completely. It enters a unique id number in the correct field upon opening the form which is what I thought I wanted at first. Now I think it would be better if after the user completes the form and presses the submit button, that that action first generates the number, enters it into the field and then sends the form to the specified e-mail address.
Is this possible?
var f = this.getField("NCR#");
var g = f.value;
if (g == 0)
var dt;
Today = new Date();
dt = Today.getTime();
this.getField("NCR#").value = dt;

Posted By: gkaiseril
Date Posted: 29 Dec 2011 at 9:37pm
Yes, but you will have to write a custom JavaScript for the submit button action.

Posted By: try67
Date Posted: 30 Dec 2011 at 12:13pm
Not necessarily. You can add the code, as it is, to a Execute JavaScript action, and then add a separate Submit Form action after that, which doesn't involve any JavaScript code.

- Acrobat Expert - Contact me personally at
Check out my custom-made scripts website:

Posted By: gkaiseril
Date Posted: 30 Dec 2011 at 8:57pm
If you want to make sure the id is added before the submit action, I would write the entire process as one action since the actions run asynchronously, that is the first action does not need to complete before the following actions are run.

Posted By: jhinckley
Date Posted: 14 Jan 2012 at 12:24am

I've thought about this some more and decided to run it in the Actions tab in the field. I've selected Mouse Exit as the trigger. Is that a good approach?

My new issue is that the number is 13 digits. Much too long. I'd like it to be six digits. Any help in modifying the original code to accomplish this would be much appreciated.

Posted By: mmazal
Date Posted: 23 Feb 2012 at 1:40pm
old post so probably done already but...
var dt;
Today = new Date();
dt = util.printd("ddmmyy", Today);
//or change the "ddmmyy" to some other format

Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 -
Copyright ©2001-2017 Web Wiz Ltd. -