Avatar

Level 7

Hi,

I have done something similar where i wanted something to run once and not run again. I was creating a form with a password. When the user opens the form for the first time, they are asked to create password, the next time they just enter the password they created. After they enter a password, an item is changed. The item is also referenced in the initialisation event and code won't trigger depending on the item. You could do it with a variable but i just used a simple TextField.

I have a hidden TextField (initialPass) with the default value 1.

form1: initialise event

if(initialPass.rawValue == "1")
{
  this.resolveNode("tblCreatePassword").presence = "visible"; //show the Create Password table
}

if(initialPass.rawValue == "0")
{
  this.resolveNode("tblCreatePassword").presence = "hidden"; //hide the Create Password table
  this.resolveNode("tblEnterPassword").presence = "visible"; //show the Enter Password table
}

In the tblCreatePassword table (consists of a TextField and a Button), the button has this code

Button1: click

initialPass.rawValue = "0"; //set initialPass to 0 so next time you do not create a password

tblCreatePassword.presence = "hidden"; //hide the create password table

If you are able to follow this:

When the form initialises, if the initialPass TextField is 1 (which it is by default on the first run), show the tblCreatePassword table. After a new password is entered in the tblCreatePassword TextField and the button is clicked. Change the initialPass TextField to 0 and hide the tblCreatePassword table.

When you save the form, the initialPass TextField (which is now 0) is saved, so next time the form is initialised, the initialPass TextField is 0 and tblCreatePassword is hidden but tblEnterPassword is shown.

Might not be a highly technical solution, but it works.