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

Form Not Savable and able to Generate Number at the Same Time

vargs
Registered: Jul 2 2010
Posts: 26
Answered

Hello,

I have this form that generates a number each time is it opened.
When opened in Adobe Reader, I can make it so that
1) The form is savable but no number is generated or
2)The form is not savable and the number is generated

I want to find a way to somehow be able to save this form while still having the form generate the number.

The form works just fine in Adobe Pro but I need to use Adobe Reader so that other people can use this form for free without any trial versions.

The code below is used to produce a random number that looks like "Form - 1284382287"

****************************
if (this.rawValue == null)
{
var d = new Date();
//divide by 1000 to get seconds and trim decimals
this.rawValue = "Form - " + Math.floor(d / 1000)
}
else
{
this.rawValue = rawValue;
}

*****************************

Any help is greatly appreciated.
Thanks,

-vargs

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Where did you place you script actually, I mean what form event?
Do you get any error in Reader when you enable the console window in the preferences dialog?

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

vargs
Registered: Jul 2 2010
Posts: 26
radzmar wrote:
Where did you place you script actually, I mean what form event?
Do you get any error in Reader when you enable the console window in the preferences dialog?
I placed the script in the initialize event type.
And I am not sure what you mean by the console window in the preferences dialog.
The error that I would get when I tried to open the form that would generate the number but would not save is that 'You cannot save a copy of this form. Please print it once completed.'

thanks,

-vargs
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The problem why the script doesn't generate new numbers when the form have been Reader enabled, is because of the script.
It will only generate a new number, if it is blank, but when you open the form in Acrobat and enable the Usage Rights the field isn't blank anymore.
The trick is to clear the field before enabling the Usage Rights.
As the field is protected in your form, so users cannot change the generated number, you need to use the JavaScript console to clear the field.

To access a field in a XFA form you need the prefix "this.xfa" in front of the regular XFA SOM expression of the form field.
In your case it has to be:

this.xfa.form.form1.omtrform.staticpage2.TextField5.rawValue = null;

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

vargs
Registered: Jul 2 2010
Posts: 26
Thanks radzmar for all your help, it is greatly appreciated.