Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

xfa.resolveNode is not writing values to the last line

Avatar

Former Community Member

Hi,

I have an issue with the xfa.resolveNode function, i have added at comment //

at below coding at the line where the issues is occuring, please advise what can be done in order to make the loop works and enter the loop for the last line.

Any help/comment is highly appreciate!

FormQuoteNotification.bdyMain.frmTableBlock.tblTable.rowTableSection.rowTableItem.colNetValue::initialize - (JavaScript, client)
var rowCount = tblTable._rowTableSection.count;
var rowNo = new Array(rowCount);
var i = 0;
var j = 0;
var k = 0;
var comboType = new Array(rowCount);
var comboPrice = new Array(rowCount);
var productID = new Array(rowCount);
var finalType = new Array();
var finalPrice = new Array();
var finalRow = new Array();
var datasum = 0.000;


for(i=0; i<rowCount; i++){

rowNo[i] = xfa.resolveNode("tblTable.rowTableSection["+i+"]").rowRemarkRow.frmItem.txtLine.rawValue;
productID[i] = xfa.resolveNode("tblTable.rowTableSection["+i+"]").rowRemarkRow.frmItem.txtProduct.rawValue;
comboPrice[i] = xfa.resolveNode("tblTable.rowTableSection["+i +"]").rowRemarkRow.frmItem.frmNetValue.decNetValue.rawValue;
comboType[i] = xfa.resolveNode("tblTable.rowTableSection["+i+"]").rowRemarkRow.frmItem.txtCombo.rawValue;

}

          for(j=0; j<rowCount; j++){
               
                if(j==(rowCount-1)){ // to check if this is the row before the last one
                    if(comboType[j]== comboType[j-1]){
                     finalType[k] = comboType[j];
                     datasum += parseFloat(comboPrice[j]);
                        finalPrice[k] = datasum;

                    }
                    else{
                     if(comboType[j] == null || comboType[j] == ""){
                      finalType[k] = "NotCombo";
                      datasum += parseFloat(comboPrice[j]);
                      finalPrice[k] = datasum; 
                      finalRow[k] = rowNo[j];
                      k=k+1;
                      datasum = 0.000;
                     }
                     else{finalType[k] = comboType[j];}
                       
                    }  
                }
                else{
                    if(comboType[j]== comboType[j+1]){
                        finalType[k] = comboType[j];
                        datasum += parseFloat(comboPrice[j]);
                        finalPrice[k] = datasum; 
                       
                         if(finalRow[k] == "" || finalRow[k] == null){
                          finalRow[k] = rowNo[j]; 
                         }                                                        
                    }
                    else{
                     if(comboType[j] == null || comboType[j] == ""){
                         datasum += parseFloat(comboPrice[j]);
                      finalType[k] = "NotCombo";
                      finalRow[k] = rowNo[j];
                      k=k+1;
                      datasum = 0.000;
                     }
                     else{                      
                      finalPrice[k] += parseFloat(comboPrice[j]);
                          k=k+1;
                         datasum = 0.000;
                     }

                    }
                       
                }              
            }

if(finalType[0] != null && finalType[0] != ""){

for(var n=0; n<rowCount; n++){
for(var m=0; m<rowCount; m++){

//-----------------------------------------------------------------------
//at this line, for the last row, even it is matching the if statement, the script is not entering for the last match of loop.
//example, if rowCount = 2, when m=1, n=1, and the if statement is matching, , but it is simply not displaying the "XXX" for the line of n=2
if(xfa.resolveNode("tblTable.rowTableSection["+n+"]").rowTableItem.colCombo.rawValue == finalType[m]
   && xfa.resolveNode("tblTable.rowTableSection["+n+"]").rowTableItem.colCombo.rawValue != ""
   && xfa.resolveNode("tblTable.rowTableSection["+n+"]").rowTableItem.colCombo.rawValue != null)
   {
    xfa.resolveNode("tblTable.rowTableSection["+n+"]").rowTableItem.colProduct.rawValue = "XXX";
   }


   
    //display comboprice
    if(xfa.resolveNode("tblTable.rowTableSection["+n+"]").rowTableItem.colLine.rawValue == finalRow[m] &&   xfa.resolveNode("tblTable.rowTableSection["+n+"]").rowTableItem.colCombo.rawValue == finalType[m]){
     var pricetodisplay = finalPrice[m].toFixed(3)+ " KWD";
     xfa.resolveNode("tblTable.rowTableSection["+n+"]").rowTableItem.colNetValue.rawValue =   pricetodisplay ; 
             
       if(xfa.resolveNode("tblTable.rowTableSection["+n  +"]").rowTableItem.colNetValue.rawValue == null || xfa.resolveNode("tblTable.rowTableSection["+n  +"]").rowTableItem.colNetValue.rawValue == " " || isNaN(xfa.resolveNode("tblTable.rowTableSection["+n  +"]").rowTableItem.colNetValue.rawValue)){
           this.rawValue = null;
        
       }
   }
  }
}
}

0 Replies