Question Details

avatar
Welcome to the Acrobat Answers site. You're on your way! It won't take you many more points to reach the next level: Participant. And as you accumulate more points, you're also building your reputation with the community and with AcrobatUsers.com.

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 778 days ago


2 Answers

avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

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:
http://www.pdfscripting.com/public/department36.cfm



Thom Parker
The source for PDF Scripting Info pdfscripting.com

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 answered 778 days ago  |   Comments (8)  |  New Comment

avatar
Welcome to the Acrobat Answers site. You're on your way! It won't take you many more points to reach the next level: Participant. And as you accumulate more points, you're also building your reputation with the community and with AcrobatUsers.com.

I setup the invisible fields what would I need to do next?

oLoan.resolveNode("aggCalc2").rawValue = oLoan.resolveNode("aggCalc").rawValue;
oLoan.resolveNode("aggCalc").rawValue = cCurrentBalance.value;
oLoan.resolveNode("aggTotal").rawValue = oLoan.resolveNode("aggCalc2").rawValue + oLoan.resolveNode("aggCalc").rawValue;

Do I need a math function? I think i am assigning them to the hidden fields correctly but cannot get the last line to work.

david romero Commented 777 days ago  |   Report


avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

The hidden fields need to be bound to the data connection. Then when you update the DB it updates it with the field values.

Thom Parker Commented 777 days ago  |   Report


avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

Oh, I thing that you are not performing the DB operations. Look in the XFA object reference for the sourceSet model functions. Or join pdfscripting.com and watch the videos that explain this in detail.

Thom Parker Commented 777 days ago  |   Report


avatar
Welcome to the Acrobat Answers site. You're on your way! It won't take you many more points to reach the next level: Participant. And as you accumulate more points, you're also building your reputation with the community and with AcrobatUsers.com.

will this work with dynamic forms i thought for a form to be dynamic you should have any fields bound to the data connection?

I'm not sure I understand entirely what you are saying. I don't need to update the DB I just need to get an aggragated total or a sum of all the records from my data connection.

david romero Commented 777 days ago  |   Report


avatar
Welcome to the Acrobat Answers site. You're on your way! It won't take you many more points to reach the next level: Participant. And as you accumulate more points, you're also building your reputation with the community and with AcrobatUsers.com.

I appreciate your suggestions but join pdfscripting.com isn't an answer its more or a sales pitch...

david romero Commented 777 days ago  |   Report


avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

Says the guy asking for free help! DB stuff isn't easy, we provide free advice for people trying to learn, not free consulting. And joining pdfscripting.com is the answer.

Thom Parker Commented 777 days ago  |   Report


avatar
Welcome to the Acrobat Answers site. You're on your way! It won't take you many more points to reach the next level: Participant. And as you accumulate more points, you're also building your reputation with the community and with AcrobatUsers.com.

So does that mean with pdfscripting.com you will do the form for me? b/c you know that would be consulting... however I concede forgive me for the confusion of this forum offering answers... to my questions ... and not suggestions to my questions.

so while you are technically offering an answer to my question, I am looking for the appropriate answer, if it is free or not is really terms of the service being offered which I thought were the terms to this service..... but I am not going to complain since it is free just plaining stating I need a different answer than pdfscripting.com

david romero Commented 777 days ago  |   Report


avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

I can guarantee you that pdfscripting.com will answer all of your questions about LC DB programming.

Thom Parker Commented 777 days ago  |   Report


avatar

  |   Report
Was this answer helpful?  
0
1

avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

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 answered 777 days ago  |   Comments (3)  |  New Comment

avatar
Welcome to the Acrobat Answers site. You're on your way! It won't take you many more points to reach the next level: Participant. And as you accumulate more points, you're also building your reputation with the community and with AcrobatUsers.com.

No worries, I myself can be unclear and wasn't clear on my task.

I have setup the data connection and setup my record pointer here:

if (cCIFnumber =="") {

app.alert("There is not a Valid CIF Number - try again!")
}
var sDataConnection = "LNMAST";

var nIndex= 0;
while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnection){
nIndex++;
}

var oDBii = xfa.sourceSet.nodes.item(nIndex).clone(1);
//app.alert(oDBii.saveXML("pretty"));

oDBii.nodes.item(1).query.setAttribute("text", "commandType");
oDBii.nodes.item(1).query.select.nodes.item(0).value = "Select * from LNMAST where CIFNumber = '" + cCIFnumber.value + "'";
//app.alert(oDBii.nodes.item(1).saveXML("pretty"));

var sOpen = "";

try {

oDBii.open();
oDBii.first();

} catch(e) {

sOpen = "failed";

}

if (sOpen == "failed") {
xfa.host.messageBox("No items found. Please try again");

} else {

nIndex = 0;
while(xfa.record.nodes.item(nIndex).name != sDataConnection){
nIndex++;
}

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

var oLoan = xfa.resolveNode("oLoan");
var hForm = xfa.resolveNode("hTitle");
oLoan.resolveNode("aggCalc").rawValue = 0;

for (var nColIndex = 0; nColIndex < cRecordii.nodes.length; nColIndex++){

switch(cRecordii.nodes.item(nColIndex).name) {

case "CurrentBalance":
var cCurrentBalance = null;

cCurrentBalance = cRecordii.nodes.item(nColIndex);
oLoan.resolveNode("aggCalc2").rawValue = oLoan.resolveNode("aggCalc").rawValue;
oLoan.resolveNode("aggCalc").rawValue = cCurrentBalance.value;
oLoan.resolveNode("aggTotal").rawValue = oLoan.resolveNode("aggCalc2").rawValue + oLoan.resolveNode("aggCalc").rawValue;
xfa.host.messageBox("N: " + oLoan.resolveNode("aggCalc2").rawValue + " | " + oLoan.resolveNode("aggCalc").rawValue + " | " + oLoan.resolveNode("aggTotal").rawValu );
break;
default: break;
}

}




}

oDBii.close();

}

I know the Data Connection is working correctly and I know how to setup a point to step threw my records what I am having issue with is actually creating a variable or field that will sum up the records as I step through each record. I intially tried doing this by creating a case statement that caught the column header here:

case "CurrentBalance": cCurrentBalance = cCurrentBalance.value + cRecordii.nodes.item(nColIndex).value; break;

I hoped it would be as simple as added the value of the node (cRecordii.nodes.item(nColIndex).value) to the variable. This was not working than i tried in my lastest piece assigning the values to different fields and than totaling the fields but the line (oLoan.resolveNode("aggTotal").rawValue = oLoan.resolveNode("aggCalc2").rawValue + oLoan.resolveNode("aggCalc").rawValue;) doesn't seem to work either.

david romero Commented 777 days ago  |   Report


avatar
<p>Congratulations! The Acrobat User Community selection team has approved your status as Expert in the Acrobat User Community. We appreciate all your past contributions and hope you will continue to support the community by answering questions and participating in the Acrobat Answers Q&A program as you've done in the past.</p>

<p>As an expert, you will get a badge to display on your profile with the level EXPERT next to your name and you have become eligible to be nominated to the Adobe Community Professional Program.</p>

<p>After reviewing the Adobe Community Professional Program information at https://www.adobe.com/communities/professionals/, please let us know if you are interested.</p>

<p>Someone from the selection team will contact you soon regarding the community professional program. Keep up the good work!</p>

<p>Regards,</p>

<p>The Acrobat User Community Team</p>


<p>**** Disclosure Requirements for Endorsements Received by Third Parties  ****</p>

<p>If you endorse or refer people to the Acrobat User Community in any venue,  it is our responsibility to ensure that you are aware of required compliance with the <a href="http://ftc.gov/os/2009/10/091005revisedendorsementguides.pdf">FTC’s Guidelines</a>. Both you and Adobe can be held liable under federal law for making unsubstantiated claims and for not disclosing your relationship with Adobe. In particular:</p>

<ol>
<li>Always disclose if you have received any type of incentive – free products, promotional items, travel, gifts, payment, and so on from Adobe. The disclosure must be on the same page as the endorsement.</li>
<li>Be truthful. Endorsements should not be misleading. Never make unsubstantiated or exaggerated claims about the benefits of Adobe products or programs. Any statements or endorsements about an Adobe product must be based on upon your actual experience.</li>
</ol>

Thank you again for your support of Adobe and the Acrobat User Community</p>

I'm not seeing the next() function used anywhere. You have to call next to go to the next record. It is as simple as you think it should be. Much, much simpler than the code you've listed.

Your DB needs to be setup so that it reports an EOF. Then you write your loop to goto the next record until isEOF() is true. each time through the loop just sum the value acquired from the record model. do the sum in a variable. Wait til the loop is finished, and then apply the sum to the form field.

BTW: this should all be done from a button script.

Thom Parker Commented 777 days ago  |   Report


avatar
Welcome to the Acrobat Answers site. You're on your way! It won't take you many more points to reach the next level: Participant. And as you accumulate more points, you're also building your reputation with the community and with AcrobatUsers.com.

Thank you I apreciate your help!

david romero Commented 776 days ago  |   Report


avatar

  |   Report
Was this answer helpful?  
0
0


Discover an easier way to work with forms.

Try FormsCentral
risk‑free for 30 days.


Other Questions Needing Answers


PDF file icon images

Asked by Jim Leavens · 2 answers