Expand my Community achievements bar.

I think it's an event problem...

Avatar

Level 10

Another one for the hive mind.

Seems to be an event ordering problem.

I'm trying to setup a form so it knows whether or not it's been used before using a form number field to drive the logic.

I'm trying to give the user three options:

Edit the existing form

Re-use the form (and generate a new order number)

Start a new form (wipe the form clean and start fresh)

On opening the form I have a popup that asks the user what they want to do if the form already has a number.

I've got the logic for driving the popup and number generation on the form:ready event of the "hidden # generator" field - outlined in a red dotted line so it's easy to see while I'm working on it.

Everything works except for the start a new form option.

The logic I started with for generating a new form didn't work:

{

xfa.host.resetData();

xfa.form.remerge();    

var d = new Date();

this.rawValue = Math.floor(d / 1000);

}

I've tried creating a script object to handle the resetData() and remerge() functions which is getting me closer but it doesn't clear the number field because after the script object fires I get the popup when I shouldn't.

But even if I explicitly blank the number field it doesn't work:

{

subMain.subHeader.RequestNo.rawValue = "";

xfa.form.remerge();

xfa.host.resetData();

}

The form resets and gets a new number but I get the popup again when I shouldn't.

scReset is the script object that does the reset routine.

I'm using AcroDialogs to make a pretty popup and the AcroDialogs code itself is part of the if statement that checks to see if the number field is empty or not. So the first few lines of the script checks for value and generates a number if the field is empty, else it drives the popup - my code for dealing with the popup choices starts at line 182.

Form is here: https://acrobat.com/#d=ZljqS5WWljYSdn1hvO6FbA

Is there a way to do what I'm trying to do or does anyone have a better idea?

2 Replies

Avatar

Level 10

Oh, and on the docReady event it almost works, the field clears but I don't get a new number.

Avatar

Level 10

Got it sorted with Niall's help - implemented a hidden button to handle the number generation that gets activated by the script with an "execEvent("click")".