Page 3 of 4
Problem in calculation input values
Posted: Thu Jul 10, 2014 4:27 am
by Prudhvi Kumar Chowdary
hi,
.
.
Above mention is the database table,
in this table i have to change the avl column with the Remaning Units as shown in below screen
.
.
as shown in above screen, i need to update the Avaliable Units with the Remaining Units on clicking Place Order Button, all those avaliable units are coming for database in loop, how tocall service pack for each entry in the database, please help me.
Problem in calculation input values
Posted: Thu Jul 10, 2014 9:43 am
by Prudhvi Kumar Chowdary
replay please....................
Problem in calculation input values
Posted: Thu Jul 10, 2014 12:10 pm
by Kateryna Grynko
Hi Prudhvi,
If I understand you correctly, available amt = sum of all avl from Database, right?
Ordo you want to obtain a value on record click and save it to "available amt ?" Please check here: http://devcenter.appery.io/documentat...
Problem in calculation input values
Posted: Thu Jul 10, 2014 12:48 pm
by Prudhvi Kumar Chowdary
Hi Katya,
not that,
I'll tell u the flow see,
This is my Opening screen
.
.
All the Goods are comes from Database in loop,
my database as showen below.
.
.
in this When i select the number of Required Units
on the base of Required Units and Avaliable Unit
the Remaining Units are calculated,
as Remaining Units =Avaliable Unit-Required units
as show in below screen
.
.
now i want that on clicking Place Order Button, Avaliable Unit value has to change with Remaining Units in database, why because when i place order the Avaliable Unit have to decrease ..
please help me....................................
Problem in calculation input values
Posted: Thu Jul 10, 2014 10:52 pm
by Yurii Orishchuk
Hi Prudhvi,
In case you've described above you need:
1 Add to your project "update items" service.
2 on "success" event of service which is "place the order" you need to run following code:
pre
//Note you should replace "shoppingItemsTable" with your shopping item table name.
var shoppingItems = Apperyio("shoppingItemsTable");
for(var i = 0; i < shoppingItems.length; i++){
Code: Select all
var currentItem = jQuery(shoppingItems[i]);
//Note: you should replace "itemIdLabelName" with label name which is inside item and contain item id.
var currentItemId = currentItem.find("itemIdLabelName").text();
console.log("currentItemId = " + currentItemId);
//Note: you should replace "itemRemaningLabelName" with your label name which is inside item and contain item Remaning Units.
var currentItemAvaliableItems = currentItem.find("itemRemaningLabelName").text();
console.log("currentItemAvaliableItems = " + currentItemAvaliableItems);
//Note you should replace "yourUpdateService" with your update service datasource name.
yourUpdateService.execute({ data: {"_id": currentItemId, "avl": currentItemAvaliableItems} });
};
/pre
This code will iterate through your all items sends update request for each item.
Also this code has some "console.log" debug information. Please checkut your console if you will have some problems.
Regards.
Problem in calculation input values
Posted: Fri Jul 11, 2014 4:46 am
by Prudhvi Kumar Chowdary
Hi Yurii,
its now working
i user this on success event
var shoppingItems = Apperyio("items");
for(var i = 0; i < shoppingItems.length; i++){
var currentItem = jQuery(shoppingItems);
var currentItemId = currentItem.find("id").text();
console.log("id = " + currentItemId);
Code: Select all
var currentItemAvaliableItems = currentItem.find("remUnit").text();
console.log("currentItemAvaliableItems = " + currentItemAvaliableItems);
itemUpdateServices.execute({ data: {"_id": currentItemId, "avl": currentItemAvaliableItems} });
};
Problem in calculation input values
Posted: Fri Jul 11, 2014 5:22 am
by Kateryna Grynko
Hi Prudhvi,
Glad to hear that! Let us know if you need any further help.
Problem in calculation input values
Posted: Fri Jul 11, 2014 6:26 am
by Prudhvi Kumar Chowdary
Sorry Sorry Sorry Sorry Sorry Sorry spell mistake not working ....
Problem in calculation input values
Posted: Fri Jul 11, 2014 8:35 am
by Maryna Brodina
Hello!
Are there any errors? Please clarify what exactly doesn't work?
Problem in calculation input values
Posted: Fri Jul 11, 2014 9:32 am
by Prudhvi Kumar Chowdary
Hi Maryna,
I'll tell u the flow see,
This is my Opening screen
.
.
All the Goods are comes from Database in loop,
my database as shown below.
.
.
in this When i select the number of Required Units
on the base of Required Units and Avaliable Unit
the Remaining Units are calculated,
as Remaining Units =Avaliable Unit-Required units
as show in below screen
.
.
now i want that on clicking Place Order Button, Avaliable Unit value has to change with Remaining Units in database, why because when i place order the Avaliable Unit have to decrease ..
i tried above code on my success event but it does't works,
please help me for this....................................