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

creating a number from a txt file

bwadsager
Registered: Feb 3 2009
Posts: 12
Answered

I'm trying to figure out how to:

Have a field in a distributed form, where a number/string from different fields are created when a button is clicked. I need the number to increase by one each time the form is filled, so that when it reaches me, the number is one higher than the last i received.

example: SW_NM01_20090505

The SW comes from a field, the NM is type of report and the 01 is the number.

I think it could be fixed by retrieving a number from a txt file, adding 1 and saving it again, so the next will be 1 bigger, but I just can't figure out how.

Anyone got an idea??

oksana77
Registered: Apr 24 2009
Posts: 89
You can retrieve 01 from SW_NM01_20090505 text by using substring.

var num = TextfiledName.rawValue.substring(4,6);

var newNum = Number(num) + 1;

And than add the rest of the string to it.
bwadsager
Registered: Feb 3 2009
Posts: 12
Oksana, thanks for your answer. I think we misunderstood eachother a bit.

I already have SW_NM, then needs to generate 01...02...03...04 and so on. This is where i would like it to find a number in a text file saved on the server, take that number, add 1 and save it again.

example: first reports number SW_NM01_20090505
second report number SW_NM02_20090505 and so on.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Look at using Acrobat's JavaScirpt 'global' object using the 'subscribe' property to keep track of the incremented number. Realize that the form need not be saved for this number to increment.

See the [url=http://www.acumentraining.com/acumenjournal.php]Acumen Journal August 2004[/url] and the associated [url=http://www.acumentraining.com/resources.php]Resouce file[/url] for a working example.

George Kaiser

oksana77
Registered: Apr 24 2009
Posts: 89
Can you save the number in xml format on server and than import the number and add one every time the form is opened?
nixopax
Registered: Feb 6 2009
Posts: 105
Yes. Basically, you would have an On Document Open action submit a form to a server that processes the XML request. From that, you can return the value in FDF format to the PDF.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
The beauty of the subscribed global object is there is not need to save a file as it is a global variable and saved automatically but with version 8 on there are security restrictions.

George Kaiser

bwadsager
Registered: Feb 3 2009
Posts: 12
Thank you all. As I'm situated in europe I will see what I can do tomorrow, but I must say it looks promising. gkaiseril do you know what the security restriction issues could be?
bwadsager
Registered: Feb 3 2009
Posts: 12
gkaiseril.

I was happy and then became sad. I do not seem to be able to overrule the security issues using the global object in lifecyle designer.

I have tried to save the script in the folder level but still i get no count in the form.
The user will have to open the form in reader 9, so I have tested it with the script saved in the javascript folder for the reader and still no counting.

Am I missing something out here?