I originally posted about this here:
https://getsatisfaction.com/apperyio/...
The idea is the same; map a service response's $ to a label in a list item. On the mapping I invoke a separate service and trigger a loop in its success event that "sums" up a field.
What I cannot get to work is taking that "sum" and returning it as the desired value to be mapped to the list's label.
This is my code so far:
var token = Apperyio.storage.user_session_token.get();
var jli = value.id;
var whereObject = {job_lineitem_ptr: {"$inQuery": {id: jli } } };
var onSuccess = function(data)
{
var sum = 0;
for (var i=0; i 0)
{
total = Number(total);
}
else
{
total = 0;
}
console.log("Total from mapping: " + total);
return total.toFixed(2) + " hrs";
And this is what is written to the console log:
The values seen in the console after "Total from Mapping: " (167) is also what is mapped to all of the labels in the list.
The summing logic appears to be correct. In this case, there are four list items, and this code is being ran once for each one. The loop code is correctly being ran a total of six times, (2 times for two list items, once for the other two).
The issue is getting the summed value back to the mapping and properly mapped to the list item's label. How can I do this?