Javascript help for unique document ID field
- June 23, 2020
- 3 replies
- 2743 views
I am very new to creating Adobe Forms and also very new to Javascript. I've been tasked at work to create a form with fillable fields that can be submitted whenever someone needs to request a new project from my department. Easily done.
The catch is that they also wanted 1) the ability to add attachments to each submission (Solved), and 2) the ability to create a unique document ID each time a submission comes in. #2 is where I'm stuck!
I did some digging through the forums and found some different javascript codes that did the trick. After experimenting, I found that the yyyymmddHHMM format works perfectly for assigning document IDs. I set the script to assign a number when the Form is opened. Everything workedgreat! ...until I "Distribute" the Form and publish it.
In short, even though I clear the fields and save the document, the Form "opens" anew and assigns a document ID in the text field when I hit Distribute to publish the Form, which makes the document ID static/permanent for anyone using that distributed form.
Any ideas on how to work around this issue?
Here is the code I tried using (not sure what most of this actually means):
function DocID()
{
}
var f = this.getField("DocID");
if (f.valueAsString=="") f.value = util.printd("yyyymmddHHMM", new Date());
