Expand my Community achievements bar.

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

addInstance Problem

Avatar

Former Community Member

I am having problem using addInstance in my form, I checked all the forums and tried lot many things still the issue is same.

I have a form with 2 pages and for second page there should be an Add button whenever I click the Add it should add the page 2 contents.

I am saving my form as dynamic also I set the repat subform max and min values.

But still I get the error

GeneralError: Operation failed.
XFAObject.addInstance:1:XFA:form1[0]:P2[0]:Add[0]:click
The element [max] has violated its allowable number of occurrences.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Here is the form back to you: https://acrobat.com/#d=G3vkuNS4xdlbTH7xVNiSEg.

You were referencing two subforms down into P2, whereas P2 was the repeating object. I changed the script to reference the repeating object:

P2.instanceManager.addInstance(true); 

You could also use the shorthand for instanceManager (_):

_P2.addInstance(true); 

You had set up P2 as flowed, so that new instance appear straight after the previous instance. So I have set up a new P3 which is positioned and new instances of this page appear on a new page. Have a look at the pagination settings.

Hope that helps,

Niall

View solution in original post

6 Replies

Avatar

Level 10

Hi,

If you select page2 and go to the Object > Binding palette, you will see a checkbox for the repeating the object. Tick this and as an option you can tick the Min of 1 (and/or a Max, and/or an initial count).

This will then allow the add button to create a new instance of page2. Please note that the new instance will be the default appearance and values of page2.

Hope that helps,

Niall

Avatar

Former Community Member

Hello Niall,

I tried that option but still I get the same error, Can I get a sample or do you want me send my form to you (it is just a simple form I am trying).

Avatar

Level 10

Hi,

If you upload your form (or sample) to Acrobat.com, publish it and then post the published URL here I will check it out when I can.

Niall

Avatar

Correct answer by
Level 10

Hi,

Here is the form back to you: https://acrobat.com/#d=G3vkuNS4xdlbTH7xVNiSEg.

You were referencing two subforms down into P2, whereas P2 was the repeating object. I changed the script to reference the repeating object:

P2.instanceManager.addInstance(true); 

You could also use the shorthand for instanceManager (_):

_P2.addInstance(true); 

You had set up P2 as flowed, so that new instance appear straight after the previous instance. So I have set up a new P3 which is positioned and new instances of this page appear on a new page. Have a look at the pagination settings.

Hope that helps,

Niall