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

Create consecutive invoice numbers

Community Beginner ,
Apr 22, 2018 Apr 22, 2018

Hi, I'm very new to Adobe and I'm wondering how I can create a running number for forms? I'm sending invoices and I'd like a unique, consecutive number on each invoice and I'm not sure how to create this. I've looked at similar questions on the forums and I understand it can maybe be done with Javascript? Like I say, I'm very new to this though and I can't seem to make it work! Any help anyone could give me would be very much appreciated!

TOPICS
PDF forms
1.5K
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 ,
Apr 23, 2018 Apr 23, 2018

You need to first define when the invoice number should update, and when it shouldn't.

In other words, what's the trigger for updating the number.

The actual update is trivial if you use a text field.

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 Beginner ,
Apr 23, 2018 Apr 23, 2018

I would like the number to update each time a form is sent to be signed, is this possible?

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

Are you using a Submit button to send it?

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 Beginner ,
Apr 23, 2018 Apr 23, 2018

I'll be sending the form for signature. Each time the form is filled out and signed, I would like a new number.

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

Something needs to trigger it, though. Just sending it out doesn't do that, unless you use a Submit button which can be set to change the value of the field before sending the file.

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 Beginner ,
Apr 23, 2018 Apr 23, 2018

Ah ok, so you'd recommend setting up a submit button? Then each time the number will change? Thanks for helping me with this btw!

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

Yes. Then it would be quite simple. Let's say you have a text field called "InvoiceID". You can run this code to increment its value by one before sending out the file:

var f = this.getField("InvoiceID");

f.value = Number(f.valueAsString)+1;

f.defaultValue = f.valueAsString;

Then you would need to save the form, and then send it.

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 Beginner ,
Apr 23, 2018 Apr 23, 2018

Ok, great. And to create a submit button, is that the same as a radio button?

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

No, it's just a button field. Not a radio button field.

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 Beginner ,
Apr 23, 2018 Apr 23, 2018

Thanks for getting back to me. For some reason the only button option I have is a radio button, yet when I open another form from the document cloud, I have the regular button tool (the little box with 'ok' in the middle) as well as the radio one. I'm not sure what's going on!

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

Click on Tools - Prepare Form and then click on "More" at the right side of the window and then on "Revert to Acrobat Form", then save the file, close it, re-open it and try again.

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 Beginner ,
Apr 25, 2018 Apr 25, 2018

Thanks, I didn't realise that Adobe sign forms and Acrobat forms were different. I really thought I had it working this time! I created a 'Submit' button and added the javascript code you gave me to the 'actions' within the button along with emailing the completed form back to me. I must have done something wrong though because the number didn't change after I submitted the form and then tried to fill out a new one.

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

Hi again! So at the moment the number is rolling over every time I save a new version of the form. Is there any way to get it to roll over every time the form is submitted? (It's emailed to me at the moment) I've tried contacting Adobe directly but they can't help with Javascript apparently! Thanks again!

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

Do you have a submit button? If so you can add a JavaScript action to it, and put your code there. Make sure it's before the submit action.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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

Yes I do have a Submit button. I've added the Javascript action first followed by Submit. I'm using the form on mobile devices though, so I share it to Fill & Sign as it requires signatures and then it is submitted to an email address. I would like the number to change after each time the form is emailed to me. Is this possible? Thanks for your help!

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

I see you mentioned fill & sign earlier. This is a problem.  However, have you tried it out? What happens. Try it before making is fill-n-sign form. then try it after, then try it on mobile and let us know what the results are.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 Beginner ,
May 04, 2018 May 04, 2018
LATEST

I have tried it. The number changes when the form is used on Acrobat on my computer, but not on the iPad. I have an idea, I also have a 'Reset' button, do you think I could add a code to the Reset button that would change the number and reset the form?

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