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

Calculate just once - serial number based on today's date

pthakur
Registered: Feb 14 2006
Posts: 10

I am setup Serial Number field on a LiveCycle PDF and it's calculated based on Today's date. Once an user fills-out form and saves it under a different name, I don't want the serial numbr to be re-calculated when this instance of the form is re-opened on another day. However, on rest of the form fields I may not want to suppress recalculation.

How do I accomplish this?

Your help will be greatly appreciated.

Thanks,
Paul

PS: This is no different than the request date on form if set to "Today's date" via JavaScript. One wouldn't want that to change each day the same instance of the request is re-opened.

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Use the "Default Value" to determine if you should do the update. When you create the form leave the 'Default Value" empty, create your script to update the Serial Number only when the Serial Number's default value is empty and when it updates the value of the Serial Number field is also updates the default value.. Clear the Serial Number's default value and save the form. The next person to open the form will have the serial Number entered in the value of the field and the default value, which prevents further updates. The advantage of using the default value is this that the default value will repopulate the Serial Number field is the form is reset for reason.

George Kaiser

pthakur
Registered: Feb 14 2006
Posts: 10
Thanks for your quick response.

I have tried this, however not having much luck. It still recalculates.

By the way I am using LiveCycle Designer and saving the form as PDF and then opening in Acrobat 7.07. In Acrobat, filled and saved under a different name and then reopend - the serial number changed than what it first showed in Acrobat. Each time it has a different value.

What event will you associate the code with? I have tried layout:ready and docReady.

What did you mean by "Clear the Serial Number's default value" - is this after I calculate? The default value in the Designer is set to empty.

Below is the code I am using:


if (this.isNull)
{
var currentDateTime = new Date();
var year = "0" + (currentDateTime.getFullYear() - 2000);
var month = "0" + (currentDateTime.getMonth() + 1);
var day = "0" + currentDateTime.getDate();
var hours = "0" + currentDateTime.getHours();
var minutes = "0" + currentDateTime.getMinutes();
var seconds = "0" + currentDateTime.getSeconds();

this.rawValue = year.substring(year.length-2, year.length)
+ month.substring(month.length-2, month.length)
+ day.substring(day.length-2, day.length)
+ hours.substring(hours.length-2, hours.length)
+ "-" + minutes.substring(minutes.length-2, minutes.length)
+ "-" + seconds.substring(seconds.length-2, seconds.length);
};
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Well since LiveCycle Designer not support the "defaultValue" field property like Acrobat forms, you will have to create a hidden field to indicate that the serial number has been competed. The ".defaultValue"property is different than the ".value" property of a field and is not supported by LiveCycle Designer.

George Kaiser