Expand my Community achievements bar.

JavaScript to Evaluate Value in an Array of Cells

Avatar

Level 3

Hi There,

I am working on a pricing table in an ordering form. I need to show a subform if any row has a subtotal above 2,000. I was able to get that script going except that when the "add row" is clicked the subform is hidden again no matter which subtotals values I have in that column. Another issue is that when edits are made to quantity and unit price the subtotal is not updating. The " delete row"  option doesn't seem to affect the script negatively. How can I get "Add row"  to correctly evaluate if any subtotal cell in the table is above or below 2,000 and show/hide the subform accordingly. And why is my calculation no updating when I change  actual and qty values?

Thanks in advance for any help!

Here is what I have:

Script in Calculate event of the subtotal (extended) cell:

if ( actual.rawValue != null || qty.rawValue != null) {

this.rawValue = actual.rawValue * qty.rawValue;

}

checkValues.compAnalysis()

Function:

function compAnalysis() {

var oFields = xfa.resolveNodes("PRForm.orderDetails.orderTable.orderLine[*].extended[*]");

var nNodesLength = oFields.length;

for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {    

nLineTotal = oFields.item(nNodeCount).rawValue;

if ( nLineTotal != null && nLineTotal >= 2000 ) {

      this.resolveNode("H-comparativeBids").presence = "visible";

      this.resolveNode("H-comparativeBids.justification").validate.nullTest = "error";

      }

    else if ( nLineTotal == null || nLineTotal <= 2000 ) {

          this.resolveNode("H-comparativeBids").presence = "hidden";

          this.resolveNode("H-comparativeBids.justification").validate.nullTest = "disabled";

          }

    }

}

0 Replies