Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to remove instances dynamically based on parameter from row objects

Avatar

Avatar
Validate 1
Level 1
PiPiLee
Level 1

Likes

2 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
PiPiLee
Level 1

Likes

2 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
PiPiLee
Level 1

24-07-2018

Hi , guys

I'm using Adobe LiveCycle 10.4.0  ES2.0.​ ​I get confusing about using removeInstance(). I want to delete the row items based on parameter from data structure.  And my codes seems noneffective. My codes in table layout:ready* is :

var valFs;

var numrows = xfa.resolveNodes("SRFS_PL_FINSTMNT_XSD_REP_DATA.bdyMain.tblLineItems.rowLineItem[*]").length;

for (var x=0; x < numrows; x++)

{

      valFs = xfa.resolveNode("$record.LISTFINSTMNT.item[" + x  + "].FSTYPE").value;

      if (valFs == "AA")

    {

        SRFS_PL_FINSTMNT_XSD_REP_DATA.bdyMain.tblLineItems.rowLineItem.instanceManager.removeInstance(x);

    }

}

Actually, the result really delete some items, but it seems delete row items randomly. Can you please answer how to use removeInstance() if I want to delete row items depend on another parameter in table? Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

24-07-2018

Hi, you should go though your table backwards, so "for (var x=numrows -1; x >= 0; x--)" as deleting rows will change the number of rows but you have already calculated numrows.

Also, you should not do this in the layout:ready event as it will cause the event to fire again, see this reference https://helpx.adobe.com/pdf/aem-forms/6-3/scripting-basics.pdf#nameddest=G6.1668520

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 1
PiPiLee
Level 1

Likes

2 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
PiPiLee
Level 1

Likes

2 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
PiPiLee
Level 1

24-07-2018

Hi BR001,

Thanks, it really works.

BR, PiPi Li