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

Auto generate a number and prevent it from updating when the form is opened

Explorer ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

Hello

I've created a form which will be uploaded to our intranet, the form has a field which automatically generates a random number when the form is opened, that works well but, the number changes when the file is saved or opened.

Initially the code was in the document processing so ran when the form was opened, I've now deleted that and added the code to the field itself but it's still changing if the user goes into the field.

This is the code I've used 

this.getField("RefNo").value = util.printf("%06d", Math.floor((Math.random() * 1000000) + 1));

It's set on a mouse up action and the locked option is also selected.

I want the number to generate when the form is opened and then lock so it doesn't change when opened again, can this be done?

I'm used Adobe Acrobat Pro 9.

Any help would be appreciated.

TOPICS
PDF forms

Views

569

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 , Dec 02, 2016 Dec 02, 2016

Move it back to where it was. Just add this line before it:

if (this.getField("RefNo").valueAsString=="")

Votes

Translate

Translate
Community Expert ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

Move it back to where it was. Just add this line before it:

if (this.getField("RefNo").valueAsString=="")

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
Explorer ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

Thank you so much,that was a super fast response and works perfectly.  You are a star

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 ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

LATEST

Hi.

You should be aware that all PDFs embed an unique "Permanent identification number" that you can use instead of creating anoter one:

http://abracadabrapdf.net/utilities-in-english/abracadabra-doc-id_en/

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