Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

response data is for wrong service

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

response data is for wrong service

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?

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

response data is for wrong service

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

response data is for wrong service

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.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

response data is for wrong service

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.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

response data is for wrong service

Hi Terry,

Thank you, we will test your app.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

response data is for wrong service

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.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

response data is for wrong service

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?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

response data is for wrong service

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

Return to “Issues”