0

Here is my current code, so far the button will create a new row in the table and it will reset the fields (AdditionalComments, CellLocation, and FailureSelection, which are all text fields), but it will not allow me to populate the original FailureRow or the new instance of FailureRow that is created:

field name="AddFailureButton" w="31.114mm" h="6mm">

        event name="event__click" activity="click"
           script contentType="application/x-javascript"
           xfa.host.messageBox("Failure Recorded, Please Continue Filling Out the Form Until All Failures Have Been Recorded.  Then Please Save and Submit the form.", "Continue/Save/Submit", 3);
           this.resolveNode('failuretable.Table1._FailureRow').addInstance(1);
           if (xfa.host.version < 8) {
           xfa.form.recalculate(1);
}

//****need to set values of current FailureRow to be equal to CellLocation, FailureSelection, and AdditionalComments, THEN clear the values as written below*****

           xfa.host.resetData("form1.page1.AdditionalComments");
           xfa.host.resetData("form1.page1.CellLocation");
           xfa.host.resetData("form1.page1.FailureSelection");
</script>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

Try the following code:

var newRow = this.resolveNode('failuretable.Table1._FailureRow').addInstance(1);
newRow.CELL_NAME.rawValue = form1.page1.AdditionalComments.rawValue;
newRow.CELL_NAME.rawValue = form1.page1.CellLocation.rawValue;
newRow.CELL_NAME.rawValue = form1.page1.FailureSelection.rawValue;

Remember to replace CELL_NAME with a proper name.

btw. When you are referencing object in the script you can just use it's SOM expression failuretable.Table1._FailureRow instead of this.resolveNode('failuretable.Table1._FailureRow').

poliglot
  • 204
  • 1
  • 7
  • awesome that worked! thanks very much. However, now the last lines of code for resetting the fields to their original state no longer work, any idea why? also thanks for the pointer on the SOM expression! – user2196209 Mar 26 '13 at 17:36
  • NVMD i tweaked it a little and it is working! Thanks so much! – user2196209 Mar 26 '13 at 18:00
  • Ok, so i updated a lot in the form and needed a larger table, i reused the table names but now the old button won't work and a new one with the same code doesn't either. Here's what i have: form1.failuretable.Button1::click - (JavaScript, client) var newRow = this.resolveNode'failuretable.failuretable._FailureInstance').addInstance(); newRow.Comments.rawValue =form1.AdditionalComments.rawValue; newRow.Location.rawValue = form1.CellLocation.rawValue; newRow.FailureCode.rawValue = form1.FailureSelection.rawValue; Any thoughts?? THANKS! – user2196209 Apr 30 '13 at 22:40
  • You have some mistakes in your code (eg. missing opening bracket in resolveNode, duplicated table name). What do you ment by writting 'reused the table names' Do you have two tables with the same name? Actually it is quite hard to tell without seeing the form what the real problem is all about. – poliglot May 07 '13 at 17:11