- Fri Nov 06, 2015 6:20 am
#784302
Dear All,
I have a stock issuing process. As part of the process the stock room does not always have the stock on hand. I created a simple script to calculate if there is a stock shortfall. Depending on if there is a shortfall, it will determine how the process continues. The items ordered are in a grid "Stock_Grid". The grid contains 4 fields "Module", "ConfirmedQuantity" which are brought in from the previous step. "PackedQuantity" is entered by the Stock Room Packer.
If there is no stock shortfall then the system must place a hyphen (-) in the text box. If there is a shortfall, the amount of the shortfall must be calculated and appear in the ShortPacked field. At the same time there is a hidden field called "SecretSum" that must be increased by the shortfall. "SecretSum" is the field that the form will use for routing.
Where did I go wrong? Irrespective of what I do this function doesn't seem to work
I have a stock issuing process. As part of the process the stock room does not always have the stock on hand. I created a simple script to calculate if there is a stock shortfall. Depending on if there is a shortfall, it will determine how the process continues. The items ordered are in a grid "Stock_Grid". The grid contains 4 fields "Module", "ConfirmedQuantity" which are brought in from the previous step. "PackedQuantity" is entered by the Stock Room Packer.
If there is no stock shortfall then the system must place a hyphen (-) in the text box. If there is a shortfall, the amount of the shortfall must be calculated and appear in the ShortPacked field. At the same time there is a hidden field called "SecretSum" that must be increased by the shortfall. "SecretSum" is the field that the form will use for routing.
Where did I go wrong? Irrespective of what I do this function doesn't seem to work
Code: Select all
Please help!!!!!!function CalculateShortStock() {
var nRows = Number_Rows_Grid("Stock_Grid", "Module");
var Ssum = 0;
for (var i = 1; i <= nRows; i++) {
getGridField("Stock_Grid", i, "ShortPacked").value = 0;
LineVal = parseFloat(getGridField("Stock_Grid", i, "ConfirmedQuantity").value) - parseFloat(getGridField("Stock_Grid", i, "PackedQuantity").value);
getGridField("Stock_Grid", i, "ShortPacked").value = LineVal;
Ssum += parseFloat(getGridField("Stock_Grid", i, "ConfirmedQuantity").value);
If getGridField("Stock_Grid", i, "ShortPacked").value = 0
{
getGridField("Stock_Grid", i, "ShortPacked").value = "-"
}
}
getField("SecretSum").value = Ssum;
};
document.getElementById("Stock_Grid").onchange= CalculateShortStock; //execute when any value in the grid changes
CalculateShortStock(); //execute when DynaForm loads