Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Form unique ID numbers

New Here ,
Aug 14, 2018 Aug 14, 2018

I need to create a field that stores a document ID number, and changes everytime I click a "Save to Pdf button". For example to start the code I need an "ID1". At the end of the form I press the button I want the document to be saved and change to "ID2" . I don't want this numbers to repeat.

TOPICS
PDF forms
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Aug 14, 2018 Aug 14, 2018

OK. In that case create a (read-only) text field (let's say it's called "ID") and add the following code to the Mouse Up event of your "Save to PDF" button:

this.getField("ID").value = Number(this.getField("ID").valueAsString)+1;

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2018 Aug 14, 2018

Is there only going to be one copy of this form, anywhere? If not, how will you prevent the copy from having the same ID as the original?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2018 Aug 14, 2018

It is only one copy for each user, stored inside their computer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2018 Aug 14, 2018

OK. In that case create a (read-only) text field (let's say it's called "ID") and add the following code to the Mouse Up event of your "Save to PDF" button:

this.getField("ID").value = Number(this.getField("ID").valueAsString)+1;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2018 Aug 14, 2018

is there a chance to Save the document in the same button, besides saving to pdf, so I can assure that the ID number never repeats, when the document is reopened.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 14, 2018 Aug 14, 2018

I would simply place the code as the document's Will Save event, under Tools - JavaScript - Set Document Actions.

Be aware this absolutely does not guarantee that. It's enough that someone goes back to an earlier version of the file for you to get duplicate IDs. If you want to ensure the IDs are unique either use random ones, instead of sequential, or assign them in a single location (for example, on your computer, after they are submitted back to you).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2018 Aug 14, 2018

is there a chance to set the ID field as the name of the document saved by user. For example the id says "ID1" and when the document is ready to save it'll appear the as "ID1.pdf"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 15, 2018 Aug 15, 2018
LATEST

No. You can't force the file to be saved under a specific name.

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