Add value of xfa.record.nodes.item to a variable?

assumming my connection and everything else is correct. I would like to do this:

  var cRecordii = xfa.record.nodes.item(nIndex);
  var cCurrentBalance = 0;

  for (var nColIndex = 0; nColIndex < cRecordii.nodes.length; nColIndex++){
   switch(cRecordii.nodes.item(nColIndex).name) {
    case "CurrentBalance": cCurrentBalance = cCurrentBalance.value + cRecordii.nodes.item(nColIndex).value; break;
    default: break;

However it is not working.

david romero

2 Answers

Wouldn't be great if it worked that way. But it doesn't, a script can read from the source model, but only a bound field can write into it. I usually setup a group of invisible fields for exactly this purpose.

You'll find videos and samples covering this topic ad nauseum at this membership site:

Thom Parker
The source for PDF Scripting Info

The Acrobat JavaScript Reference, Use it Early and Often

The most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Having trouble, Why Doesn't my Script Work

Thom Parker   

Ok, lets start over. You never explained what it was you were trying to do. I'm sorry I didn't ask you to explain more up front. I thought that you were trying to write back to the DB.

In order to add the records you have to position the record pointer. This is standard for any DB programming on any platform. So #1 you have to learn about the Source set model and it's functionality.

Thom Parker   

Please specify a reason: