Expand my Community achievements bar.

Repeating subform and remembering no# of instances?

Avatar

Level 4

We have a form with a Primary subform and a Repeating Dependent subform.

The repeating subform has a min count of 0 (which clears out), max = 5 and a init of 1.

We have reader extended the forms so you can save.

When we click "Add Dep" (so there is 2) and save.  Close REader.  Reopen reader, the form has 1 Primary + 2 Dependents (as expected).

However, if we click "RemoveMe" so there is just the primary, Save and Close Reader, and then reopen, the form opens with 1 Primary and 1 Dependent.  However the last state of the form was just 1 Primary.

Is there a way so that if we save with no Dependents that it remembers?  Unfortunately we cannot start the form with 1 Primary and NO dependents since we will have ppl who will just print out the form and fill out by hand.  Nor can we just leave it as is, since we validate that all the fields are populated before submitting.

BTW, i can't seem to be able to upload the file..So here is a snapshot from Designer.

SubFormObj.JPG

The code behind the Add Dep button (Click event) is

Page1._Dep.addInstance();

The code behind the Remove Dep button (Click event) is

Dep.instanceManager.removeInstance(this.parent.instanceIndex);

4 Replies

Avatar

Level 10

Hi,

First just check that the File > Form Properties > Defaults tab, the "Preserve script changes" is set to Automatic.

Preserve script changes.png

However I suspect that it is the initial count that is catching you. When the form opens it sees that the count is zero and creates an initial instance.

If it still is not working come back,

Niall

Avatar

Level 4

it is set to automatic.

i agree, its the init that seems to bugger it all up..

Avatar

Level 10

Okay,

Just thinking about it, if there was a mandatory field in the subform that had to be filled out, then you could try a script in the docReady event. This could check the value of the mandatory field and if it is null then delete that instance.

It is not fool proof, becuase if the user leaves it blank, saves the form and comes back to it, the instance would be deleted when they reopen, losing the rest of their data. Not good!

Hmmm, my brain has stopped working. Will have to think about it and see is there a way around.

Niall

Avatar

Level 2

I believe this is working as implemented. Setting "Initial Count" to 1 does just that on initialise.

Your requirement (as i understand it) is to be able to print a blank form.

Maybe remove the Initial Count. Add a "Print Blank Form" button (maybe up in the top right corner) and script the addition of the Dependant subforms, to the Max count, then execute the print function.