The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Quantity in Stock field not populating the sum value

Joshua Comeau
Kilo Sage

 

I have the following code but it is not working it is giving back NaN

function onLoad() {

var qtystock1 = g_form.getValue('u_stockroom_1');
var qtystock2 = g_form.getValue('u_stockroom_2');
var qtystock3 = g_form.getValue('u_stockroom_3');
var qtystock4 = g_form.getValue('u_stockroom_4');
var qtystock = 0;

    qtystock1 = parseInt(qtystock1, 10);
    qtystock2 = parseInt(qtystock2, 10);
	qtystock3 = parseInt(qtystock3, 10);
	qtystock4 = parseInt(qtystock4, 10);
    qtystock = parseInt(qtystock, 10);
//Calculation
 var qtyorder = qtystock1 + qtystock2 + qtystock3 + qtystock4;

  g_form.setValue('quantity', qtyorder.toString());
    }

 

1 ACCEPTED SOLUTION

Joshua Comeau
Kilo Sage

This worked appears the issue resided more towards consising the code and the field was missing "quantity"

function onLoad() {
    var qtystock1 = parseInt(g_form.getValue('u_stockroom_1_quantity'));
    var qtystock2 = parseInt(g_form.getValue('u_stockroom_2_quantity'));
    var qtystock3 = parseInt(g_form.getValue('u_stockroom_3_quantity'));
    var qtystock4 = parseInt(g_form.getValue('u_stockroom_4_quantity'));

    {var qtyorder = qtystock1 + qtystock2 + qtystock3 + qtystock4;}
    g_form.setValue('quantity', qtyorder.toString());
}

View solution in original post

1 REPLY 1

Joshua Comeau
Kilo Sage

This worked appears the issue resided more towards consising the code and the field was missing "quantity"

function onLoad() {
    var qtystock1 = parseInt(g_form.getValue('u_stockroom_1_quantity'));
    var qtystock2 = parseInt(g_form.getValue('u_stockroom_2_quantity'));
    var qtystock3 = parseInt(g_form.getValue('u_stockroom_3_quantity'));
    var qtystock4 = parseInt(g_form.getValue('u_stockroom_4_quantity'));

    {var qtyorder = qtystock1 + qtystock2 + qtystock3 + qtystock4;}
    g_form.setValue('quantity', qtyorder.toString());
}