I am trying to create a a form for Work Orders that will be able to generate it's own sequential work order number. I have zero Java experience, so I am really fumbling in the dark with everything that I've done.
I have a text field set up for the WO number, and I have created a button that, when pressed, clears the form, adds 1 to a variable that I've created, set sthe text field to that variable, and saves it as a new file:
[b]xfa.host.resetData()
WOnum=WOnum+1
WO.rawValue=WOnum
app.execMenuItem("SaveAs")[/b]
So far, this is working. The problem that I run into is that once I enter data and save the form, if I reopen it, it resets the variable WOnum back to 0 - It doesn't save the value of the variable after the program closes.
At first I realized that part of the problem was my variable definition. I had the code to define the variable as:
[b]var WOnum = 0[/b]
in a docReady event. This was resetting the variable to zero each time the document was reopened. I tried to change the code to something that would check for a variable value, and if there wasn't one (ie, it hadn't been created), it would define it and set it to zero:
[b]if(WOnum){}
else{var WOnum=0}
[/b]
I don't know if what I've written is actually doing what I thought though. Obviously, it's not working as intended, but I don't know if it's this piece of code, or some other issue. Does the program automatically reset a variable after it closes?
I would really appreciate any help in getting the field to retain it's value after the program is closed and reopens.
WO.rawValue++;
app.execMenuItem("SaveAs");