While creating a new sales order using dynamics NAV SOAP webservices, getting below error while attempting to create multiple line items. Order info with single line item being added successfully.
Error - The Sales Line already exists. Identification fields and values: Document Type='Order',Document No.='1111',Line No.='10000'
Here is my code that I have tried :
$client = new SoapClient($soapWsdl, $options);
// Create order header
$create = new stdClass();
$sq = new stdClass();
$sq->OrderType = "Order";
$sq->OrderId = "1111";
$create->SalesOrderWS = $sq;
$result = $client->create($create);
$key = $result->SalesOrderWS->Key;
$update = new stdClass();
$sq->Key = $key;
$sq->CustomerID = "9999";
$salesLineList = new stdClass();
$salesLine = new stdClass();
$salesLine->Order_Type = 'Order';
$salesLine->OrderID = '1111';
$salesLine->LineType = 'Item';
$salesLine->OrderLineNo = '10000';
$salesLineList->Sales_Order_Lines_WS[0] = $salesLine;
$sq->SalesOrderLinesWS = $salesLineList;
$salesLine = new stdClass();
$salesLine->Order_Type = 'Order';
$salesLine->OrderID = '1111';
$salesLine->LineType = 'Item';
$salesLine->OrderLineNo = '20000';
$salesLineList->Sales_Order_Lines_WS[1] = $salesLine;
$sq->SalesOrderLinesWS = $salesLineList;
$update->SalesOrderWS = $sq;
$result = $client->Update($update);
Certainly, something is missed here, but couldn't identify the problem.
Thanks.
Debug next
. If it is 2009, then you need Visual Studio to debug. – Mak Sim