Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

loop not working for check of duplicate values in a repeating table

Avatar

Level 3

I have a form that is used for marking down problem items, describing the problems and assigning a value to the specified item. In some cases the problems belong to the same class. When they do, the value associated with the problem should only be marked once. If another problem in the same class is documented the value should not be recorded the second time. I have a variable that is called based on a switch statement in the exit event of the field that records the problem item number. The script in the variable is then supposed to check for duplicate values in the table. If no other problem item in that class is selected, then the problem value should be assigned a number. If another item from the same class has already been entered, then the problem value should just be left blank. I will paste the script for the variable below as well as the switch statement. When I used to call the variable based upon the change event for the problem item, the script work. At that time, the switch statement was related to a drop-down menu. We decided to get rid of the drop-down and just have the used type the item number. But to do so, I had to move the switch statement to the exit event for the field. when I did this, the script in the variable no longer worked properly. Here is the switch statment followed by the script in the variable:

this.rawValue = this.rawValue.toLowerCase();
var bEnableTextField = true;
var i = "Inspection Criteria: ";
var r = "Required Corrections: ";
switch (this.rawValue)
{
  case "1a": // 1a- First debit option
    CorrectionsText.CorrectionLang = r+"Correction description for 1st debit";
    ViolCorrSection.ViolationsText.DebitVal = "C";
    ViolCorrSection.Reference.RefLanguage = i+"1st debit reference";
break;

  case "1b": // 1b- Second debit option
    CorrectionsText.CorrectionLang = r+"Correction description for 2nd debit";
    ViolCorrSection.Reference.RefLanguage = i+"2nd debit reference";
    myScript.group1();
break; //the script continues for various item numbers...

________________ variable script ________________________

function group1()
{
//Used in checking duplication of violations
var oFields = xfa.resolveNodes("form1.MAINBODYSUB.ViolationsTableSubform.ViolationsTable.ViolCorrSection[*].ViolationsText.ItemNo"); // looks to resolve the repeating rows
var nNodesLength = oFields.length; //assigns the number of rows to a variable
var currentRow = xfa.resolveNode("form1.MAINBODYSUB.ViolationsTableSubform.ViolationsTable.ViolCorrSection").index;
var currentDebit = xfa.resolveNode("form1.MAINBODYSUB.ViolationsTableSubform.ViolationsTable.ViolCorrSection[" + currentRow + "].ViolationsText.DebitVal");

for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) // this loops through Item Numbers looking for duplicate violations
{
//console.println("nNodeCount: " + nNodeCount);
var nFld = xfa.resolveNode("form1.MAINBODYSUB.ViolationsTableSubform.ViolationsTable.ViolCorrSection[" + nNodeCount + "]");
//console.println("nFld.ViolationsText.ItemNo: " + nFld.ViolationsText.ItemNo.rawValue);
     if (nFld.ViolationsText.ItemNo.rawValue == "1a" || nFld.ViolationsText.ItemNo.rawValue == "1b" || nFld.ViolationsText.ItemNo.rawValue == "1c" || nFld.ViolationsText.ItemNo.rawValue == "1d") // looks for other 1s
     {
          currentDebit.rawValue = "";
          nNodeCount = nNodesLength;  // stop loop
     }
     else
     {
        currentDebit.rawValue = "5";
     }
}

}

So, if you enter 1b the first time, you should get a value of 5 appearing in the debit value field. If you enter 1c next, because it belongs to the same group of class of problem items, there should be no value assigned. What happens now is that the values for 1b and 1c don't appear at all because the form thinks that the first 1b entry already existed.

Any ideas? I have a stripped down version of the form that I can email to someone for reference if that would help. Thanks

P.S. I am working with LiveCycle Designer ES 8.2.1....

2 Replies

Avatar

Level 10

Hi,

I can have a look at your form, but can you host it somewhere like Acrobat.com or google docs and add a link to it here.

Regards

Bruce

Avatar

Level 3

Hi Bruce,

I posted it on Google docs and sent you a message with the link.

Thanks

Dave