Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

How to make a javascript function execute in the order I write it


Level 1

I have a function in the click event of a button: ();

xfa.form.remerge ();

textfield1.access = "open"

Row1 and row2 works but row3 does not because I understand java is working in an asynchronous state.

All rows run at the same time but remerge takes more time and it ends last. So in the very end, it makes textfield1 to its default state, read only.

How can I make these three rows execute in the order I write them? How can I make row3 waits to run until row2 ends?

6 Replies


Level 10

Its because of the effects of the remerge method. Its forces the PDF viewer to create a new form DOM from the template and data DOMs. During this process all pending scripts will be terminated.


Level 1

OK, is there a way to run remerge for only a limited section of the form? For example remerge all form but TextField1.


Level 10

Not that I'm aware of. You have to find another solution to control the access property ot the textfield.


Level 7

what does not work for row 3? when you remerge you essentially are resetting the form back to its original state. What state does row 3 start out in? what happens to it after remerge


Level 1

textfield1 is read only by default. By pressing the button, user should reset the whole form and only then would enter data in textfield1. On the other hand after pressing the button, form data and structure resets but textfield1 remains read only. Row3 can not create any change. textfield1 should become open but it remains read only. I think its because of the asynchronous nature of java code. Row3 do its job in the first place. But all three lines run at the same time and because of this, Row2 kills Row3's action.

My purpose is to avoid people to share already filled forms between each other and then submit them as they personally filled it. textfield1 is for a unique tax id number and a person at least must change this field to fill the form properly.

So if the code works, a person can not enter his tax id number to textfield1 just after opening the form because it is read only. The only way to proceed would be pressing the button, by doing this he resets all the data and form structure + make textfield1 open so he can enter data to it. After entering tax id number, I have a seperate code that makes textfield1 read only again. So whenever you want to change the tax id number, you must reset all the form and structure.

I was thinking that this is a good work flow but it does not work.

Is there a way first "xfa.form.remerge ();"  and AFTER THEN "textfield1.access = "open"?

On the other hand, if I can remerge a form partially, it would also work.


Level 7

What if you left textfield1 as open. You could lock the field on an exit event.

1- user enters data in field1

2- on exit the field is set to read only

3- next user clicks the button to reset the form

4- form is reset to its original presence.

5- textfield1 is open

The issue is that remerge seems to be a final event. Nothing executes after that.