API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Why cant i make OrderLine_CreateFromData work?

0
I want to make a set of orderlines.

My question is about the syntax of CreateOrderLineFromData

Why dont this work:

function CreateOrderLineFromData($client,$orderHandle,$productHandle,$amount,$price){
             $client->OrderLine_CreateFromData(array(
                                                        'orderHandle' => $orderHandle,
                                                        'ProductHandle' => $productHandle,
                                                        'Quantity' => $amount,
                                                        'UnitNetPrice' => $price,
                                                    ))->OrderLine_CreateFromData;

}

When this do work:

    function CreateOrderLines($client,$orderHandle,$productHandle,$amount,$price){
 
            $orderLineHandle = $client->OrderLine_Create(array(
                                                        'orderHandle' => $orderHandle,
                                                        ))->OrderLine_CreateResult;
            $client->OrderLine_SetProduct(array(
                                            'orderLineHandle' => $orderLineHandle,
                                            'valueHandle' => $productHandle
                                        ));
            $client->OrderLine_SetQuantity(array(
                                            'orderLineHandle' => $orderLineHandle,
                                            'value' => $amount
                                        ));

            $client->OrderLine_SetUnitNetPrice(array(
                                        'orderLineHandle' => $orderLineHandle,
                                        'value' => $price
                                    ));

}
 

Can any body give me a tip?

Regards Christian Heyn
created Aug 23, 2013 by cheyn
87% Accept Rate
Q 15 A 6 C 7

1 Answer

0
 
Best answer
I have now tryet to first do Orderline_Create, and then in Orderline_CreateByData fill in the Handle. That works.

But is it not possible to do OrderLine_CreateByData without first creating the orderline?
answered Aug 23, 2013 by cheyn
selected Aug 28, 2013 by cheyn
I fund the solution my self.

An orderlines handle consist of 2 data. Id and Number.
Id is the id of the orderhandle.
Number is the linenumber for the orderline.

So just use set orderline->id = order->id
Visma e-conomic A/S
...