This topic contains 5 replies, has 0 voices, and was last updated by Anonymous 10 years, 9 months ago.
- May 18, 2010 at 10:41 am #497
Hello, I have a form, on the form a input box, on a form open event a set field behavior > special > form instance number.
All I ever get in the input box is 0, no matter how many instances I make.
Clearly not doing something right.
ThanksMay 18, 2010 at 10:54 am #5265
Say I just read another post from a month ago were you explained that the Instance Name and Number are generated at the first submit.
I changed my behavior to run on the forms submit and close(form has only one submit), but still only get 0 as a form instance number.May 18, 2010 at 12:49 pm #5266
Run your ‘set field’ script when the form loads in the next stage. The instance number is created when the form is submitted, so if you are running this BEFORE the submit (as you seem to be) it will do what you are seeingMay 18, 2010 at 4:27 pm #5267
If your forms go to a closed stage immediately after the first submission (which some of mine did) you will need to handle it with something like this. This was a solution given to me by one of the pf techs.
This will require one “hidden helper” text input field (txtFormSubmitted) to work correctly, with a default value of 0. In the form is opened event, at the beginning, you will add a simple branch that checks if txtFormSubmitted is equal to 1. If that is false, than just connect that to the normal behaviors you would want to run when the form is opened. If that is true than connect the branch to a run behavior command. This run behavior command should be set to run the behavior of your submit button.
Next you will need to modify the behavior of your submit button. For this, your submit button must be a regular button with a submit behavior so that you can add these extra behaviors. In your submit button is clicked event you will need a simple branch. That simple branch will check if txtFormSubmitted is equal to 0. If that is false, you will connect it to a set field command that sets txtFormSubmitted = 2. If that is true, you will connect the branch to a set field command that sets txtFormSubmitted = 1. After setting it to 1, you will want a set next stage command and set it to your first (default) stage. After that, add a Submit Data command with “Re-open Same Instance” checked.
So what you will end up with is the form first opens, and txtFormSubmitted will be set to 0, and your normal “form is opened” behaviors will execute. Then when the user submits the form the branch will see that txtFormSubmitted is set to 0 and will then set it to 1, set next stage to the default stage, and submit the form and re-open the instance. You will see the form open after it submits, but it happens very quickly. When the form re-opens, the branch you set up in the form is opened behavior will re-run the submit button is clicked event. This time the branch will see txtFormSubmitted is not equal to zero and will set it to 2. It has to set it to something other than 0 or 1, or the next time you open the form it will not work properly. After you set txtFormSubmitted to 2, you can add a set field to capture your form’s instance name.
This will allow you to capture it at the first stage. I hope that makes sense, it’s kind of hard to describe. It may sound kind of convoluted, but I’ve built that into all my forms and it works very well.May 18, 2010 at 6:25 pm #5268
Thanks, this is my situation and it dose sound kind of convoluted, but I will work my way through your explanation.
I got part way there using Ian explanation above but was not able to get all the parts and from your description probably would not have gotten there on my own.
TimMay 18, 2010 at 7:12 pm #5269
Thanks tmrhymer, was not quite as convoluted in the doing as in the reading, again thanks for taking the time to write out the explanation works very well!!!!
You must be logged in to reply to this topic.