There’s a bug currently logged against Acrobat 7.x where removing an instance of a dynamic subform, using the Instance Manager (IM)’s removeInstance(int) method, doesn’t cause an update to the IM’s count of currently instantiated subforms.
OK, so maybe that was a little too technical so I’ll try to simplify: In Acrobat 7.x, when you remove an instance of a dynamic subform using the IM’s removeInstance(int) method and then check the number of remaining instances using the count property, the number you’ll get won’t reflect the number that remains.
Adobe is aware of this bug and will hopefully be providing a fix for it in an up-coming release.
Fortunately, there’s a simple work-around (and even if the bug gets fixed in a future release, you should probably be checking the version of Acrobat that’s running your form to determine whether you need to be using the work-around or not):
_DynamicSubformInstanceManager.removeInstance(3); // Force a remerge of the form's current data set with its template // to cause an update to the "count" property of all IMs xfa.form.remerge();
Calling the Form object’s remerge() method will “force the remerging of the data model and template model to re-create the form model”, as explained in the Adobe XML Form Object Model Reference. This means that the form’s current data set will be remerged with the template (the form objects like dynamic subforms, fields, etc.). The result will be a form that looks exactly the same as it did in its state just prior to calling xfa.form.remerge() but with all IMs properly updated to the current number of dynamic subforms which they’re managing, thus correctly updating each IM’s count property.
// get the host's version as a string and split it into an array var oVerArray = xfa.host.version.split("."); if (oVerArray == "7") xfa.form.remerge();
Or more simply:
if (xfa.host.version.split(".") == "7") xfa.form.remerge();
Posted by Stefan Cameron on May 25th, 2006
Filed under Instance Manager,Scripting
Both comments and pings are currently closed.