create subform using addInstance(), rename the subform, delete it later
Posted on 2006-11-27
I have a form where users can enter a case number and click a button. The button then creates 3 subforms throughout the main form using addInstance(). In the first subform there is a button that says "Delete Section". Once that is clicked I want all 3 subforms to be deleted. The user may have created a number of sections so I need to identify the correlating two sections.
I thought I could just rename each subform based on the case number that the user entered and then reference each subform to be removed that way, but it doesn't work.
I can 'apparently' rename the subform, but when using the new name when using removeInstance() it doesn't work.
Test rename of subform:
// this is in the initialization parameter of the field containing the policy number
this.rawValue = "123"
app.alert(this.parent.name); // provides the current subform name correctly.
this.parent.name = this.rawValue; // should change the subform name to "123"
app.alert(this.parent.name); // shows the value "123" which is what I would expect and want
if I now click a button saying: ._123.removeInstance(0);
it doesn't work.
If I now click a button saying: .OriginalFormName.removeInstance(0);
So it doesn't appear that the subform name is really being changed at all. It's a ruse :-(
Any help would be great.