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

Locking field after print or save as

Joe McDermott
Registered: Nov 25 2010
Posts: 4

Hi all, I am new to Live Cycle and fairly new to scripting so I am hoping this is just a stupid noob question.
 
Here we go. I have a form that has a job ticket number that is generated with the the following code:
 
$ = concat(Num2Date(Date(), "YY-JJJ-"), Num2Time(Time(), "KKMMS"))
 
That part works good and honestly without this site I dont think i could have gotten this far.
 
What I need is for that particular field to be locked or remain the same after the user prints or saves as. So when it is pulled up at a later date the ticket number will be the same. Hope that all makes sense.
 
Thanks in advance.

My Product Information:
LiveCycle Designer, Windows
Masi
Registered: Sep 18 2008
Posts: 22
Joe McDermott wrote:
$ = concat(Num2Date(Date(), "YY-JJJ-"), Num2Time(Time(), "KKMMS"))

Is the ticket number generated during saving or printing? If so, then you could put the script with a small if-statement into those events (prePrint, preSave):

if ($ == null) then
$ = concat(Num2Date(Date(), "YY-JJJ-"), Num2Time(Time(), "KKMMS"))
endif

This if-statement will check that the current value is null (empty) and only then generate the ticket number. After the first time, the value is not null (it contains the ticket number) and the ticket number is not generated.
(if that doesn't work, try with $.isEmpty inside the if-statement)
Joe McDermott
Registered: Nov 25 2010
Posts: 4
Thanks, it makes sense but it doesnt quite work. It still wants to recalculate after it is saved then reopened. I have decided to generate my numbers in my access database now. There were to may variables doing it based on time. I am now having issue getting the auto number field to import into the document.