Hi Mark,
Sure, you can pass there any value you need.
Regards.
Hi Mark,
Sure, you can pass there any value you need.
Regards.
Hi Yurii
when use that code the results returned is empty. if the value of producty is 6 and the value of stockqty is 5, I want 11 to be displayed
Hi Mark,
May be problem in string value of your parameters.
Please try to use following JS code:
pre
"Qty_in_Cup": (parseInt(productqty) + parseInt(stockqty))
/pre
Regards.
Hi Yurii
That code also failed. It also erases the value which was stored in the database
Hi Yurii
Please ignore. The code works ok
Hi Yurii
One last question How do I add a Math.ceil to the stockqty value. So for example
"Qty_in_Cup": (parseInt(productqty) + parseInt(stockqty) return Math.ceil)
Hi Yurii
I have also worked out the Math.ceil command. But I have another problem. Some values are received as 0.65 for example and I need to round this value up to 1. If I use the Math.ceil command it returns the value 0. What command can I use to round any value under 1 up to 1?
Hi Yurii
Please ignore. All working using a if statement )
Hi Yurii
I still have a slight problem with this. Here is my current server code.
var DB_id = "54ae8e1ce4b042777ffe572c";
var collectionName = "CupboardStore_Coll";
var productid = request.get("productid");
var newproductname = request.get("newproductname");
var productbarcode = request.get("productbarcode");
var deptName = request.get("deptName");
var shelfid = request.get("shelfid");
var productqty = request.get("ProductQty");
var itemName = request.get("itemName");
var Product_Desc = request.get("Product_Desc");
if (productqty < 1)
Code: Select all
{ productqty = 1
};
var query = [] ;
try
{
// result = {};
var result = [];
var params = {};
params.criteria =
{
Code: Select all
//Barcode: productbarcode
ASDAcin: productbarcode
};
Code: Select all
query = Collection.query(DB_id,collectionName,params) ;
if (query.length === 0)
Code: Select all
{
Collection.createObject(DB_id, collectionName, {
"Barcode": productbarcode, "Product": newproductname, "Qty_in_Cup": productqty, "Qty_Max": (parseInt(productqty) + 1), "Consumed": 1, "Restock_Level": 0, "Restock_Flag": productqty, "Restock_Qty": 1, "ASDAcin": productbarcode, "deptName": deptName, "shelfid": shelfid, "Substitutions": false
});
} else{
Code: Select all
for (var i=0; i < query.length; i++){
var currentObject = query[i];
Collection.updateObject(DB_id, collectionName, currentObject["_id"], {
"Qty_in_Cup": parseInt(currentObject["Qty_in_Cup"]) + (parseInt(productqty))
, "Consumed": parseInt(currentObject["Qty_Max"]) - (parseInt(currentObject["Qty_in_Cup"]) + (parseInt(productqty))), "Restock_Qty": parseInt(currentObject["Qty_Max"]) - (parseInt(currentObject["Qty_in_Cup"]) + (parseInt(productqty))), "Restock_Flag": (parseInt(currentObject["Restock_Flag"]) + (parseInt(productqty))),
"deptName": deptName, "shelfid": shelfid, "Product_Desc": Product_Desc, "CrossOff_SL": false
Code: Select all
});
}
response.success(result);
}
} catch (e)
{
Code: Select all
response.success("message: " + e.message + "ncode: " + e.code);
}
*****When I upload the first set of products all works ok.
when re upload the first set of products. The "Qty_in_Cup" Column in the database updates as required
However If I add a new set of products. The columns in the database are emptied.
How Can I fix this?
Can anyone else on the support team help me with this??