insertInstance fails on second row

Avatar

Avatar
Validate 1
Level 1
formerizer
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
formerizer
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
formerizer
Level 1

26-02-2017

InsertInstance function doesn't seem to work on Row1[2] and beyond but it works for Row1[0] and Row1[1].

Basically insertInstance generates errors whenever there's more than 1 row instances premade inside Designer.

Error: Index value is out of bounds

Picture below is of object hierarchy.

Each "+" button calls the addRow function inside the script object

Script Object

1137769_pastedImage_2.png

How can I fix this?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile
_Bruce_Robertson
MVP

06-03-2017

Hi,

I think radzmar is correct in suggesting renaming the rows.  The index property in a reference like currentObj.parent.parent.index is meant to return the position in like named objects, which in your case includes "Row1[0]" you have defined in the template.  So it is not insertInstance you are having trouble with but the index property.

You can use an expression like;

     xfa.resolveNodes('Table1.#subform.[layout=="row"]')

to return a list of all the rows in a table regardless of the rows name.

Regards

Bruce

Answers (5)

Answers (5)

Avatar

Avatar
Validate 1
Level 1
formerizer
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
formerizer
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
formerizer
Level 1

06-03-2017

I use resolveNodes to count the number of rows on the form and label each text cell (nodetxtnum.rawValue) with the row number.

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

06-03-2017

Sorry, makes no sense to me. What code uses the resovelNodes() method?

Avatar

Avatar
Validate 1
Level 1
formerizer
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
formerizer
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
formerizer
Level 1

05-03-2017

Thanks for the response.   I'm aware of the workaround of naming each row uniquely. 

Because the code uses length from resolveNodes to count the number of rows, all the rows have to remain as instances not unique names.

Is there a way to work this without remaining the rows?

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

04-03-2017

Instead of naming all rows "Row1", you should name them individually.

The script then could be:

if (this.parent.parent.instanceManager.count < 100) {

    this.parent.parent.instanceManager.addInstance(true);

}

Avatar

Avatar
Validate 1
Level 1
formerizer
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
formerizer
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
formerizer
Level 1

03-03-2017

has anyone else had this issue?