Expand my Community achievements bar.

Changing the Field Names

Avatar

Level 2

Hi,

I am dynamically adding rows to a table using the following code

SheetIndexForm.Page1.tblSheets.trSheet.instanceManager.addInstance(true);

The rows cells are all text fields for user data input. Rows are getting added perfectly fine along with the text fields. The only issue I am facing is that all the new rows have the same name as the first row. Is there anyway I can change the name of the new row to something else. I tried

newRow.name = "trSheet" + newRowIndex.toString();

but it does not work. The XFA field names will still be the same.

3 Replies

Avatar

Former Community Member

The field name will be the same but the row that they are from will be unique. So If the Row subform is called Row  and the field is called field you will have Row[0].Field, Row{1].Field, Row[2].Field...etc

Now how do you reference that in an expression seeing as the [ ] are used for arrays in Javascript. You would need teh xfa.resolveNode("string .....") sytax. So if you want to add all three values you woudl use ths sytax:

Total.rawValue = xfa.resolveNode(Row[0].Field).rawValue + xfa.resolveNode(Row[1].Field).rawValue  + xfa.resolveNode(Row[2].Field).rawValue

Or if you want to more sophisticated:

for (i=0;i<Row.instanceManager.count;i++){

     Total.rawValue += xfa.resolveNode("Row[" + i + "].Field).rawValue

}

Note that the count is 1 based but th einstances are 0 based!

Hope that helps

Paul

Avatar

Level 2

Paul, Thanks for your answer.

However, what I am trying to do is to read this form data from a third party library called Quick PDF which allows extracting XFA form data using the field names. Unfortunately, it does not support array like syntax for referencing the form fields.

The Adobe itself will create array for rows like trSheet[1...n], but when I am reading from this library, I need to give it a absolute name lile

Form/Page1/Table1/trSheet/txtSheetName

If I manually add rows then I can give each row a different name (trSheet1, trSheet2.. etc), but however I am dynamically adding the rows to table, I was looking for a way to change the row names when doing so.

Thank

Shreedhar

Avatar

Former Community Member

Then I do not see how you will do this ...when you add an Instance you are basically cloning what is there already (making a copy of the object).

Doesn't sound like that software (QuickPDF) deals with dynamic forms very well.

Paul