These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Unique ID for Invoice

jpsimi
Registered: Jun 7 2009
Posts: 5
Answered

Please can someone help me explain how i can generate a unique ID for invoices to be printed or to be sent via mail using Adobe LiveCycle. My form is already designed; just need the form to generate a UniqueID(invoice Number) each time a form is to be sent.

Thank you.

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The fact is, you can't do this securely without a external/server solution.
A script in your form, that will create something like a time stamp is not secure enough, because the time can be manipulated easily on the pc.
Also, if you use the form on several pc's at the same time, you can't ensure, if there are't forms with the same time stamp.
So you need a external source like a database, where the forms get their unique numbers from.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
I don't think the OP is bothered as much about security as uniqueness - if the invoice is being sent as form data, it's not going to be secure at all.

"Unique" in mathematics is an absolute property - i.e. there is no possible repetition of numbers even with an infinite number of copies, which for a distributed solution is possible but only with a heck of a lot of math. For 99% of users what they actually want is "statistically non-repeated" - there is a negligible chance two copies within their system will be the same, given the number of forms submitted. That's far easier to aim for, as something relatively simple like an MD5 of the system timestamp with a random number appended will have so many permutations, you'd need billions of submissions to hit a match.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
If you are working in multiple timezones, cosider obtaining the UTC time and date to genereate your unique ID from that value.

George Kaiser

eopi
Registered: Dec 14 2009
Posts: 12
Well if I can get an idea of how to do this "If you are working in multiple timezones, cosider obtaining the UTC time and date to genereate your unique ID from that value." then that would be great.

Also, if you want a Unique ID consider obtaining name initials of the individual filling out your form. When data is obtained concatenate the TIME (if I can figure out how to get it), the DATE and the Initials.

That is a trick used in drug Clinical Trials.
jonom
Registered: Jan 31 2008
Posts: 133
FormCalc has a Uuid() function, but it generates a fairly unwieldy string like [b]3c3400001037be8996c400a0c9c86dd5[/b] or [b]1a3ac000-3dde-f352-96c4-00a0c9c86dd5[/b].

Here's a script I've used on the Initialize event of a form. It checks to see if it already has a value and if so doesn't generate a new number in case people save the form and reopen it:

The number is unique to the second, so two people would have to open the form at the same second to get the same value...

if (this.rawValue == null) {var d = new Date();//divide result by 1000 to get seconds and round off this.rawValue = parseInt(d / 1000);}else {this.rawValue = rawValue;}
eopi
Registered: Dec 14 2009
Posts: 12
jonom wrote:
FormCalc has a Uuid() function, but it generates a fairly unwieldy string like [b]3c3400001037be8996c400a0c9c86dd5[/b] or [b]1a3ac000-3dde-f352-96c4-00a0c9c86dd5[/b].Here's a script I've used on the Initialize event of a form. It checks to see if it already has a value and if so doesn't generate a new number in case people save the form and reopen it:

The number is unique to the second, so two people would have to open the form at the same second to get the same value...

if (this.rawValue == null) {var d = new Date();//divide result by 1000 to get seconds and round off this.rawValue = parseInt(d / 1000);}else {this.rawValue = rawValue;}
Ok, thanks and it works but when I open and re-open in Adobe Acrobat 8 Professional it sometimes gives the same number. I wait a few minutes and it still give the same number.

Now, I have noticed when I then open it in Adobe Lifecycle Designer and check the Preview PDF tab, as opposed to the Design View, I do see the change. Almost every second, when I toggle between the two pages.

#####973
#####974
#####975

You get the idea. So how to fix the Adobe Acrobat portion?

Details or my process:

In Design View I have a Date/Time Field.

Layout --> Caption Position --> NoneShow --> InitializeI inserted your JavaScript

Enter Script Source Changes

Language: Javascript
Run at Client

Done.

Did I do something wrong?
eopi
Registered: Dec 14 2009
Posts: 12
BUMP, any ideas?
eopi
Registered: Dec 14 2009
Posts: 12
eopi wrote:
BUMP, any ideas?
Ok, I'm satisfied.

I search and found this link
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?pid=58324#p58324

It gives Paul Guerette's lecture on Email, Lock file, Attachement and Unique Ids.

It works.

It changes when I open and re-open.

Thanks all it's put to rest.
jonom
Registered: Jan 31 2008
Posts: 133
Glad you got it going - there should be no difference in what happens between the Preview and Acrobat as they are the same thing...Preview calls Acrobat and displays it in the Preview tab.

The only thing I can think of is that you are using a date field, I use a text field to store the number.