Page 1 of 1

response data is for wrong service

Posted: Sat Jul 12, 2014 2:06 pm
by Terry Gilliver

I am very confused.

I have a create order service with the following mappings and success event:

Image

The create_order service successfully adds a record to the Orders collection:
Image

The next thing I do is to loop through the order items so that I can add the individual order items to my LineItems collection. The first thing I have to do is get the product id from the ProductItems collection. This is done by the following code snippet:
pre
//get product item id from item
get_product_id.execute( {
data: {"where": '{"Item":"'+item+'"}'},
success: successFunction(data)
});
/pre
When I check the successFunction data response it seems to have the response for the create_order service, rather than the get_product_id service? it returns an object containing the order id rather than an object containing the item id

I can't work out why the response data is from the wrong collection


response data is for wrong service

Posted: Sat Jul 12, 2014 3:23 pm
by Alena Prykhodko

Hello,

Please provide us with more details about get_product_id service (settings, request, response, mapping tabs screen shots will help)
Where do you run code of get_product_id execution?


response data is for wrong service

Posted: Sat Jul 12, 2014 4:21 pm
by Terry Gilliver

The get_product_id service has the following request, response and mappings:

Image

Image

Image

Image

By the way, the code for get_product_id service is in the success event of the create_order service. It can be seen here:
pre
console.log('Order table written successfully');
//success function for get_product_id
function successFunction(data) {
console.log("response data");
console.log(data);
}

// now need to add the order items
var item;
var quantity;
for (i = 1; i < shoppingBasket&#46;length; i++) {
&#47;&#47;get item and quantity
item = shoppingBasket[0];
console&#46;log("item = " + item);
quantity = shoppingBasket[1];
console&#46;log("quantity = " + quantity);
&#47;&#47;get product item id from item
get_product_id&#46;execute( {
data: {"where": '{"Item":"'+item+'"}'},
success: successFunction(data)
});
}
/pre


response data is for wrong service

Posted: Sun Jul 13, 2014 10:48 am
by Alena Prykhodko

Hello Terry,

Still not clear, please share your app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and tell its name.


response data is for wrong service

Posted: Sun Jul 13, 2014 7:26 pm
by Terry Gilliver

I have shared my app Dougies Meats with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a

login as admin, password ravine.123, select Get Dougie, followed by New Order-New and then select a category. Us e the plus buttons to add items and then click the checkout button and OK the alert box. Turn on debugging in the browser and select the console log. Click save. The object shown at the bottom of the log is the response from the get_product_id service. The id shown in the returned object is the create_order id, not the id from get_product_id.


response data is for wrong service

Posted: Sun Jul 13, 2014 7:39 pm
by Illya Stepanov

Hi Terry,

Thank you, we will test your app.


response data is for wrong service

Posted: Tue Jul 15, 2014 7:04 pm
by Kateryna Grynko

Hi Terry,

This is because you output in console data of create_order service, while service get_product_id is not used anywhere on the page.


response data is for wrong service

Posted: Tue Jul 15, 2014 11:10 pm
by Terry Gilliver

I am not sure what you mean. Does this mean I can't execute the get_product_id service from within the success event of the create_order service? If so, how can I make sure that the create_order service has completed successfully before I write out to the order details collection?


response data is for wrong service

Posted: Wed Jul 16, 2014 9:03 am
by Evgene Karachevtsev

Hello Terry,

There is the error in your code. You should replace this

pre get_product_id&#46;execute({
data: {
"where": '{"Item":"' + item + '"}'
},
success: successFunction(data)
});/pre
with this
preget_product_id&#46;execute({
data: {
"where": '{"Item":"' + item + '"}'
},
success: function(data) {
successFunction(data);
}
});/pre