Copy link to clipboard
Copied
I have a form created, but still a novice. So extended steps may need to be provided(more than likely)- just being honest since I am searching for help.
I have created a form that will be posted in one location and used by multiple people. I need to add a unique id for each as a new document is created. I do have the form set up with a "submit form" to a specific email address as a PDF, for management signature.
I do have a read only text field set up named: GL_ID. And I just don't know how to create it to make the magic. This unique identifier can be from 6-8 characters. I would like to attach the magic to the submit button, however it can generate the number upon opening of the document.
Please note that any guidance is welcome
jd
You can use this code as document level script:
this.getField("GL_ID").value = Math.floor(Math.random() * (99999999-999999) +999999);
Every time you open document it will generate random number in GL_ID field.
Copy link to clipboard
Copied
You can use this code as document level script:
this.getField("GL_ID").value = Math.floor(Math.random() * (99999999-999999) +999999);
Every time you open document it will generate random number in GL_ID field.
Copy link to clipboard
Copied
AWESOME thanks for the response!! now here is the novice part... ummmm where do I place this. sorry and thanks in advance
Copy link to clipboard
Copied
You can also open document level script while in prepare form mode by pressing SHIFT+D
After that click "Close" and thats it.
Copy link to clipboard
Copied
Hi Nesa,
I liked the script, however, my requirement is to generate a serial number for every PDF form. The scenario is to simply open my form, the field named PV# should automatically populate with a unique serial number. So when I open the form for the first time today, the read-only field named PV# should show the number 1, when I open the document next time to generate a new receipt, the field PV# should show the number 2.
Can the above be scripted?
Copy link to clipboard
Copied
Yes, but the number will only be unique if only you open the file. Also, if you save the file (even under a different name), the next time you open it the number will update, which is probably not what you want. You need to define a way of making the number stick, for example by flattening it, or otherwise finalizing it.
Copy link to clipboard
Copied
I believe this is what I need. Each time I open the same document to generate a receipt, the number will be higher than the previous time.
Copy link to clipboard
Copied
I don't think it will work like you think it would, but the code to do it is very simple.
Create a (read-only) text field called "Counter" and add the following code under Tools - JavaScript - Document JavaScripts (NOT inside of a function):
this.getField("Counter").value = Number(this.getField("Counter").value)+1;
Copy link to clipboard
Copied
Thanks mate, will try it š
Just tested it, works fantastically. I added a button to reset the form. It resets the number back to 1. I will be careful how to use itā¦ many thanks.
Copy link to clipboard
Copied
Thank you for your grate respond. How can we change the code format?
For example;
ABC-Random Number-XYZ
OR
ABC-Random Number
Thanks in advance...
Copy link to clipboard
Copied
And one more question, is there possibility to change this number clicking by a created button?
Copy link to clipboard
Copied
By the way, you can make it random, easily enough, but that is not guaranteed unique. If it MUST be unique then you are going to need to store all the numbers you have given out in a central place, making this a much more complex process, needing you to pay for a server to be there 24/7 to keep the info.
Copy link to clipboard
Copied
the form will be stored on our sharepoint, but i can give up the unique for random. We run a program for free 30 minutes of leave for quality notifications. Unfortunately with telework the employee would not be able to submit the paper, so we have to have soe sort of accounting or a few bad apples will use the leave repeatedly. So basically giving the leave a "serial number" will allow the tracking.
Thanks in advance !!
Copy link to clipboard
Copied
PDF format specs. requires an unique ID number for each PDF file, you should use it instead of reinventing the wheel š
Copy link to clipboard
Copied
i looked at that prior to posting, and being honest, it was greek. I am a novice, compared to you guy.... but think of this, I'm a rocket scientist on this stuff to them. i just taught them how to add the signature field, but when i tried to have them add the submit button with it.... i lost them. š so i know they would not accept hunting that information, oh and those are my superiors..lol