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

Click event of a button only delets one subform and after doesn`t work

Avatar

Avatar
Validate 1
Level 2
sc203718
Level 2

Likes

3 likes

Total Posts

12 posts

Correct Reply

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

Avatar
Validate 1
Level 2
sc203718
Level 2

Likes

3 likes

Total Posts

12 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
sc203718
Level 2

16-01-2019

The project is done in Adobe LiveCycle Designer in JavaScript.

I have an add button which adds one instance of a subform and a delete button which deletes one instance of a subform.

When i click delete it deletes only one subform. If i click it again it does nothing...What should i do ?

//form1.tabelAnexa.Row[1].veg2.veg1.prod.instanceManager.removeInstance(form1.tabelAnexa.Row[1].veg2.veg1.prod.instanceManager.count-1);

_veg1.removeInstance(1);

var rd = frmO.caption.value.resolveNode("#text").value;;

if (frmO.rawValue == null){

app.alert("Mai intai trebuie sa completati campul: " + rd + "!");

xfa.host.setFocus(frmO);

xfa.host.openList(frmO);

}

else{

/*

   This button will Remove the current instance of the repeating subform or table row.

   bCalc: Flag - true if the removed instance might be referenced by other calculations, otherwise false.

   message: The error message displayed.

*/

var bCalc = true;

var message = "Ați atins numărul minim de elemente permise.\n\nVor fi sterse datele introduse in campurile acestui element!";

// DO NOT MODIFY THE CODE BEYOND THIS POINT - 10.0.2.20120224.1.869952.867557 - Subform_Instance_Controls_IRM.xfo.p4

var oWrapper = this.parent.parent; // The outer subform built in to the object, enclosing the button group.

var oTargetSubform = oWrapper.parent; // The subform or table row the controls are intended to manipulate.

var oManager = oTargetSubform.instanceManager; // Get the instance manager.

var nMinCount = oManager.occur.min; // Get the minimum number of subform occurrences allowed.

var nSubCount = oManager.count; // Get the current number of instances.

// Proceed if the minimum number of subform occurrences has not been reached.

if (nSubCount > nMinCount) {

// Invoke the Instance Manager.

oManager.removeInstance(oTargetSubform.index);

// Fire the form calculations.

if (bCalc == true) {

// Execute all the form calculations.

xfa.form.recalculate(1);

}

} else {

var raspuns = xfa.host.messageBox(message,"Remove Item",2,2);

if (raspuns == 4){

_prod.setInstances(0);

_prod.setInstances(1);

}

}

// END OF DO NOT MODIFY

}

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,077 posts

Correct Reply

155 solutions
Top badges earned
Springboard
Validate 1
Ignite 3
Ignite 1
Establish
View profile

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,077 posts

Correct Reply

155 solutions
Top badges earned
Springboard
Validate 1
Ignite 3
Ignite 1
Establish
View profile
Magus069
MVP

16-01-2019

Hi there,

to correctly remove a subform with a button inside it with additional code, you must make sure to remove that subform at the end of all code.

What is happening here, is that you have a button within a subform, and it has numerous lines of code, on the first line it removes itself from the form... just by removing its instance the code cannot continue to execute because the object doesn't exist anymore...

So make sure to execute all of your code that does not include the object itself and once everything is done, only then you can remove the parent's instance of the object.

I hope this will help

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 2
sc203718
Level 2

Likes

3 likes

Total Posts

12 posts

Correct Reply

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

Avatar
Validate 1
Level 2
sc203718
Level 2

Likes

3 likes

Total Posts

12 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
sc203718
Level 2

17-01-2019

Thanks it works, i put the remove instance code at the end and it works

Avatar

Avatar
Boost 10
Level 3
altrue990
Level 3

Likes

10 likes

Total Posts

73 posts

Correct Reply

14 solutions
Top badges earned
Boost 10
Give Back
Validate 1
Boost 5
Boost 3
View profile

Avatar
Boost 10
Level 3
altrue990
Level 3

Likes

10 likes

Total Posts

73 posts

Correct Reply

14 solutions
Top badges earned
Boost 10
Give Back
Validate 1
Boost 5
Boost 3
View profile
altrue990
Level 3

16-01-2019

Check the minimum and maximum count for the subform to make sure they are set correctly.