execute a service in javascript
I need to add multiple records (rows) to a collection 'LineItems' after a record has been added to the 'Orders' collection. I propose to do that in the 'success' event of the 'create_order' service.
code
console.log('Order table written successfully');
// now need to add the order items
var item;
var quantity;
for (i = 1; i < shoppingBasket.length; i++) {
item = shoppingBasket[0];
console.log("item = " + item);
quantity = shoppingBasket[1];
console.log("quantity = " + quantity);
// add record (execute service)
add_order_item.execute({});
}
/code
These are the collections:
I am unsure how to format the parameters for the service. bearing in mind that some of them are pointers.
Also will the looped services execute synchronously(one after the other)? although since these do not reply on each other, it probably doesn't matter.