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

Form unique ID numbers

New Here ,
Aug 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

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

Views

1.6K

Translate

Translate

Report

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

correct answers 1 Correct answer

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;

Votes

Translate

Translate
Community Expert ,
Aug 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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;

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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).

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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"

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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