Expand my Community achievements bar.

Add 1 to a field on docReady

Avatar

Former Community Member

Hello,

Can anyone tell me how to add 1 to a field when a form is loaded? I have a field that I have set the default value to 0, but each time the form is loaded, I want to add 1 to that field, increasing the number by 1 each time the form is opened.

Thanks in advance for any insight!

3 Replies

Avatar

Level 10

Hi,

The docReady event is the right one to go for, because you are guaranteed that this will only fire once.

Something like this should work for a numeric field:

this.rawValue += 1; 

Works here, provided the form is saved before it is closed again.

Niall

Avatar

Former Community Member

Thanks for the reply Niall! It almost worked, I just had to change the += to =+ and it worked. Thanks again!

Avatar

Level 10

Hi,

I am glad you have it working, but I am surprised += didn't work. It is the standard notation for addition and assignment. Never mind...

I was thinking afterwards that if you have a reset button, you would need to assign the value of the counter to a variable before the reset line, and then set the value of the counter back to the variable value after reset.

Niall