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

How to get PDF to auto generate new invoice number everytime it is open

Guest
Jan 09, 2015 Jan 09, 2015

Copy link to clipboard

Copied

I need a unique invoice number to show in the corner of a form.  I was thinking of the best way (maybe the easiest?) to generate a number..  I want the form when opened to automatically create this number.  In addition, one the PDF has been filled out and so on, then saved, I dont want that invoice number to regenerate once its opened again for whatever the reason.  Does this sound possible?

TOPICS
PDF forms

Views

73.8K

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 , Jan 12, 2015 Jan 12, 2015

My bad... The code should be:

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

Votes

Translate

Translate
replies 139 Replies 139
Community Beginner ,
Feb 28, 2017 Feb 28, 2017

Copy link to clipboard

Copied

Thank you very much try67 you have saved me many many hours (or milliseconds).

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 ,
Oct 06, 2017 Oct 06, 2017

Copy link to clipboard

Copied

I entered the code, but it does not automatically change the number.  I have to go into the calculation field in the form, open/close, save and then I get a new number.  This is the code I used.

  1. this.getField("Number")=util.printf("%06d",Math.floor((Math.random()*500)+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
Community Expert ,
Oct 06, 2017 Oct 06, 2017

Copy link to clipboard

Copied

You should not use the code as a calculation script, but as a doc-level script.

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 ,
Oct 06, 2017 Oct 06, 2017

Copy link to clipboard

Copied

I tried it there too. Still does not auto populate the numbers.

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 ,
Oct 06, 2017 Oct 06, 2017

Copy link to clipboard

Copied

Check the JS Console for error messages.

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 ,
Apr 13, 2018 Apr 13, 2018

Copy link to clipboard

Copied

I use"Fill and sign pdf forms" in my android device , what script need to use becose in this soft. Have only save buton, and when i click change original file name.(Maybe need me when save , or save as file)

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 Beginner ,
Aug 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

Hello i'm a novice when it comes using the PDF unique numbers, and the code. I have multiple log in portals that are assigned to different team members. When a member logs in I want to have a unique id populate. Will the methods that have been explained work for me in this instance or will I run into trouble since their are multiple portals utilizing the same PDF?

Once the PDF is filled out I have a submit button that will e-mail the PDF to the correct party members. At this point I want the unique number to be saved in my DB so it won't be utilized again.

Am I in over my head here, or is this something I can easily accomplish? Or would making a single portal with one user name and one password be the necessary route to accomplish the process?

Any advice and or assistance will be greatly appreciated. Thank you in advance. This article has already been extremely helpful in my form.

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 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

You can use the code above to generate random invoice numbers.

You can then export the form data and import it into your DB, but you can't prevent duplicates from happening (at least not at the PDF level). However, if you use a long random number (for example, 10 digits long), the chances of that happening are minuscule.

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 Beginner ,
Aug 02, 2018 Aug 02, 2018

Copy link to clipboard

Copied

Could I link the log in portals to start the invoice number with letters specific to the user? Example: ms-10010001 or bg-10010001 so only my numbers could be duplicated but they would still be unique since the serial has a static value?

Thank you for responding so quickly...This thread has been extremely useful for this process.

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 02, 2018 Aug 02, 2018

Copy link to clipboard

Copied

That's going to be tricky... Why not simply assign the invoice numbers on your end, after the files have been 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
Community Beginner ,
Aug 02, 2018 Aug 02, 2018

Copy link to clipboard

Copied

When you say assign invoice numbers on my end do you mean manually?

I'm going to have multiple users 500+ given access to the PDF...When the PDF is submitted to my DB I'm tracking who the PDF belongs to in the even a customer calls me concerning their product....as long as they have the ID number that is on their copy of the PDF i'll have a copy available to know what their agreement is.

Your assistance is greatly appreciated. Thank you in advance.

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 ,
May 17, 2019 May 17, 2019

Copy link to clipboard

Copied

Is it possible to "Lock" and "Unlock" the automatically generated invoice number? Thank 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 ,
Sep 10, 2022 Sep 10, 2022

Copy link to clipboard

Copied

hi there, 

can somebody help me to creat a new PDF Invoice Form which it will automate the invoice numbering for every new invoice. 

 

 

thanks in advance. 

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 ,
Sep 16, 2022 Sep 16, 2022

Copy link to clipboard

Copied

I need to add unique invoice number to a form that will auto-populate the new number every time the form is saved. The number needs to be 2022-IN-20000 with the new number following as 2022-IN-20001 and so forth. Can anyone help? Thanks

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 ,
Apr 30, 2024 Apr 30, 2024

Copy link to clipboard

Copied

LATEST

I need help. I have been reading all the threat and I'm still not getting the pdf auto generate the number. Can someone explain me how to do it? I'm newby, but I need to create a PDF that can generate the number when its open.  Thank you in advanced!

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