Skip navigation
Currently Being Moderated

So close but need help comparing strings in different subforms with for loop - Livecycle ES

Apr 3, 2012 7:03 AM

For some reason I was not able to post this in the Livecycle ES forum, even though I've posted there often in the past.


I have created a form that I almost have working and I'm hoping someone can help me.


We have eight billing teams in our company and each team works anywhere from 1 - 4 different clients. The form is used to track, per Billing Rep, the number of items of mail that each billing r5ep works each day. What I'm needing to add at the bottom is a subform that tracks the totals by client. So I'm trying to get the form to loop through all of the existing subforms (and the subforms within them) and compare a cell int he bottom subform to a cell in the other subforms, which are dynamically added, and then total ONLY those items. My script however is not working.


What I have now is:


var repCount = form1.P1._rep.count

var itemCount = form1.P1.rep._ItemSet.count


for (x=0; x<repCount; x++)


     for (i=0; i<itemCount; i++)


          if(clientName.rawValue == P1.rep[x].ItemSet[i].client.rawValue)


          this.rawValue = this.rawValue + P1.rep[x].ItemSet[i].corresp.rawValue;





It seems like this should work but I'm getting the following error:


P1.rep[x] is undefined

So what it looks like is I'm missing is the proper way to reference the objects in these subforms.


The form is here:

If someone could take a look at it I would be so grateful.




  • Currently Being Moderated
    Apr 3, 2012 7:31 AM   in reply to joflo723

    Sorry I cant see your document link - probably have to publish it first. However from looking at the script you are using array notation in javascript to access object collections. The hierarchy object model is not a javascript array but rather a collection of dom objects even though the som expressions use them as accessors in formcalc for example.


    clientName.rawValue == P1.rep[x].ItemSet[i].client.rawValue


    would be invalid javascript since rep is not an array. Probably would need to be P1.resolveNode("rep[x].ItemSet[i]").client.rawValue

    Mark as:
  • Currently Being Moderated
    Apr 3, 2012 11:29 PM   in reply to joflo723

    Your if statement has a ; at the end basically making the test redundant and executing the code block following at all times. You also should not do - this.rawValue = this.rawValue + ... since it will keep adding on every calculate. Start from 0 in a local variable and assign it to the rawValue at the end.

    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 8:16 AM   in reply to joflo723



    Have a look at this version.


    I have used a variable to keep track of the subtotal and then apply that after the loops.


    Also I would not use x as a variable name, as it is a reserved word.


    Hope that helps,



    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 4:16 PM   in reply to joflo723

    Sorry Jo,


    But I am out of the office this week and can¹t get to have another look at

    your form. I will have a look as soon as I can.



    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