I want to create a form-number based on the date and time.
I've created a FormCalc script that works in Livecycle, but in Acrobat Pro it doesn't work (a fixed number appears, based on the date and time of the PDF i created in LiveCycle)
if (Hasvalue(Field)) then
null
else
Field.rawValue = concat ((num2date(date(), "DDMMYYYY")), (Num2Time(time(), "HHMMSS")))
endif
The number has to be locked.
But with my solution it wil regenerate after resetting the form.
Is there a better solution?
Views
Replies
Total Likes
Trying an other solution gave the same problem
if ($.rawValue==null)then
$.rawValue = Concat(Num2Date(date(), "DDMMYYYY"), Num2Time(time(), "HHMMSS"))
else
$.rawValue
endif
The Preview in LiveCycle works perfect.
But after exporting to PDF, the field has the creation date/time of the PDF.
Of cource resetting the fields results in a new generated number.
This brings me to the folowing problem.
If i get it to work, then i have to open the PDF in Acrobat Pro to enable the Reader Rights.
So opening the pdf and resetting the fields will generate the number.
Can anyone tell me how to do this?
Views
Replies
Total Likes
I've tried it with a Javascript and placed this at "form:ready"
This seems to work
if (xfa.resolveNode("Field").rawValue != null){
}
else
{
xfa.resolveNode("Field").rawValue = util.printd("ddmmyyyyHHMMss", new Date());
}
But when i reset the form, the number is also reset
Is there a way to prevent a Field to be reset?
Views
Replies
Total Likes
Hi,
You could move the script to the docReady event, as I don't think this will be affected by the reset.
Hope that helps,
Niall
Views
Replies
Total Likes
That's the problem
I need to enable the Reader Rights
So i have to reset that field one time
Any suggestions?
Views
Replies
Total Likes
Hi,
Do you need the number to reflect when the form is developed/deployed?
Or do you need the number to change every time the form is opened by the users and submitted?
Niall
Views
Replies
Total Likes
It's for a declaration form, the user must download this from a server.
The number must be generated when the user opens the form the first time.
When the user saves the document, that number must also be saved, so the same number will show up when the user opens that form again.
It's not permitted to change that number (not even on reset)
I hope you understand my poor English
Views
Replies
Total Likes
Hi,
Your English is fine, and I think I know what you are trying to achieve.
It would be easier if you were using the full LiveCycle Enterprise Suite. This server product allows for a workflow and could assign a unique number to the form.
If you are using LC Designer to generate a form and then deploy it standalone then it becomes more difficult to control a unique number.
I think that having the script happen when the form is opened is complicated, as it will change every time the form is opened. You could set the reference number based on a field or fields being not-null. See example here: https://acrobat.com/#d=E4m9qZun8wUBkaSQnR8gNA
To get around the reset problem, you could assign the reference number to a variable; reset the form; and then reassign the variable to the reference number field. Again this is in the sample above.
If you do a search in this forum you will see how other users have tackled the unique number problem.
Hope that helps,
Niall
Views
Replies
Total Likes
Found the answer (i think it's stupid that it works this way, but who am i....)
I've used this script to generate my number
That number will be saved with the PDF and doesn't change when i save, close and open the pdf again
if (xfa.resolveNode("FieldName").rawValue != null){
}
else
{
xfa.resolveNode("FieldName").rawValue = util.printd("ddmmyyyyHHMMss", new Date());
}
Now comes the fun part
I've created a script object with the script above and put a script reference at: myField -> Form:ready
Now when i open the PDF in Acrobat Pro, the number shows up and can be saved as i want.
But when i reset the form, my number disappears and a new number generates after i save, close and reopen the PDF.
BUT!!! When i insert the complete script at: myField -> Form:ready
Then a new number will be generated after i reset the form
Can you explain this behaviour?
Now i've used the last option, so a new number will generate on reset.
For saving the form with Reader Rights enabled, i created a button with a script that makes the number field empty and the button hidden:
FieldName = ""
ButtonName.presence = "hidden"
Views
Replies
Total Likes
Hi,
If you are only using the script once, I would keep it in the form:ready event of the object. It really only makes sense to use a script object if you are reusing the script several times in the form.
Also you shouldn't have to resolveNode the object in your script.
You could simplify the script by testing == null instead of != null, for example:
if (FieldName.rawValue == null)
{
FieldName.rawValue = util.printd("ddmmyyyyHHMMss", new Date());
}
I have updated the example to reflect your method: https://acrobat.com/#d=7MTJmmhWCVSfQQir3XwxXQ
In order to get over the reset button generating a new number, you could add to the standard reset script to save the current reference number into a variable.
var vRef = referenceNumber.rawValue;
xfa.host.resetData();
referenceNumber.rawValue = vRef;
The purpose of the last button is clear, because the reference number will be set when you open the form in Acrobat to apply the rights. Good catch.
Niall
Views
Replies
Total Likes
Thanx a lot!
It works perfect
Views
Replies
Total Likes
Is it possible to get a script for a shorter length of generated numbers? e.g a comb of 4 - 5 numbers?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies