My Products
Help
JarlK
PARTNER

Create order and orderLines in one request

by JarlK

I'am trying to create order and orderLines in one request using Order_Input and OrderLine_Input variables (see attached request). I have problem finding out how to pass the OrderNo to the method creating the orderlines.  
I have seen the how to guid in the documentation, but it will be nice to have the Order and OrdeLines input as variables.   Does anyone know if this is possible?

1 REPLY 1

by Marius Bancila

This is not possible, because you cannot use a variable inside another variable.

The orderNo is a variable, that gets its value set after executing the order_create field. You can't use it in the variable for order lines.

 

I suggest two alternatives:

- You pass all the data you need for the order lines as inputs (variables) and use it accordingly in the query. I know this limits you to a fix number of order lines.

- You execute two queries. The first to create the order and get back the order number. Then you build the variables programmatically, putting the order number in the dictionary and execute the second mutation for creating the lines.