Hello,
I have a removeInstance tied to a button in the click event. I know this will generate a default Adobe error if the minimum number of rows have been reached.
I would like to replace the default Adobe error of "index out of bounds" with a more user friendly error message.
I tried this after the removeInstance, but default error still popped-up:
xfa.host.messageBox("Delete error encountered. Maximum number of rows deleted.", "Warning",1,0)
Can someone offer assistance?
Thanks
Hi,
You could wrap your removeInstance script in an if statement that looks at the number of instances.
if (Table1._Row1.count > 1) {
Table1._Row1.removeInstance(this.parent.index);
}
You could turn off the Acrobat debugger from automatically opening when an error is encountered (see preferences), but that wont help users.
Hope that helps,
Niall
Hi,
The script looks reasonably in order. Can you check that the language is set to JavaScript (and not FormCalc).
I suspect the relative references could be shortened. It just depends on where the button is relative to the repeating row.
Just to note in my previous script the underscore (_) in front of the repeating object name is shorthand for instanceManager. So _TableBodyRow.removeInstance(this.parent.index) should work.
Also, the parameter for the removeInstance() method is the instance number that you want to remove - based on a zero numbering system. So your script will always look to remove the second row. You probably don't want this, so if the button is in the repeating row, passing this.parent.index as the parameter will work better.
Hope that helps,
Niall
North America
Europe, Middle East and Africa
Asia Pacific