Skip navigation
kdjeter
Currently Being Moderated

Error Handling (How To?)

May 22, 2012 11:15 AM

Tags: #error #handling

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

 
Replies
  • Currently Being Moderated
    May 22, 2012 12:29 PM   in reply to kdjeter

    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

     
    |
    Mark as:
  • Currently Being Moderated
    May 24, 2012 12:39 AM   in reply to kdjeter

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points