Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Run Code once on form load

Avatar

Former Community Member

Hi Guys,

I have a text field (TextField1)  that populates with a value (1-100)

On initial load of the form this value will be the highest.

As the user navigates around the form this number will change (lower than the initial load)

I have another text field (TextField2) on the form which I want to hold the initial value at load of the form.

something like: TextField2.rawValue = TextField1.rawValue

But whichever event I put it in it always updates TextField2 with the value in TextField1 (it does not only run the code once on form load)

Can anyone advise how I can achieve this?

If the form loads with the number 70 as a value in TextField1 - TextField2 has 70 as a value and keeps that value regardless of what TextField1 changes to..

Many thanks for any help

1 Accepted Solution

Avatar

Correct answer by
Level 7

try putting in the docReady event of TextField2:

$ = TextField1.rawValue

View solution in original post

4 Replies

Avatar

Correct answer by
Level 7

try putting in the docReady event of TextField2:

$ = TextField1.rawValue

Avatar

Former Community Member

Thanks whyisthisme,

I tried this,

The form loads and both fields show the latest number (70)

but when TextField1 is changed the value in TextField2 disappears?

it does not repopilate even if I repopulate TextField1 with the original value (70)

Thanks for your help

Avatar

Level 7

Is there any other code in or relating to TextField2?

Avatar

Former Community Member

Ok - after a closer look i think I have found it.

The docReady event works fine and the form locks off if i manually change the value in TextField1.

As part of the script that changes the value in TextField1 there is an xfa.form.remerge() and I think this is what is stopping it from working.