When I create a SalesOrder with multi DocumentDetails in PHP, here is my code
$SO301000Submit->commands = array
(
$acumatica->prepareValue("SO", $SO301000GetSchema->OrderSummary->OrderType),
$SO301000GetSchema->Actions->Insert,
$acumatica->prepareValue("ACTIVESTAF", $SO301000GetSchema->OrderSummary->Customer),
$SO301000GetSchema->DocumentDetails->ServiceCommands->NewRow,
$acumatica->prepareValue("HQ", $SO301000GetSchema->DocumentDetails->Branch),
$acumatica->prepareValue("AALEGO500", $SO301000GetSchema->DocumentDetails->InventoryID),
$acumatica->prepareValue("WHOLESALE", $SO301000GetSchema->DocumentDetails->Warehouse, true),
$SO301000GetSchema->DocumentDetails->ServiceCommands->NewRow,
$acumatica->prepareValue("VA", $SO301000GetSchema->DocumentDetails->Branch),
$acumatica->prepareValue("AAPOWERAID", $SO301000GetSchema->DocumentDetails->InventoryID),
$acumatica->prepareValue("RETAIL", $SO301000GetSchema->DocumentDetails->Warehouse, true),
$SO301000GetSchema->Actions->Save,
$SO301000GetSchema->OrderSummary->OrderNbr
);
$result = $acumatica->client->SO301000Submit($SO301000Submit);
It will return the error
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at PX.Api.SyImportContext.ParseCommand(SyCommand cmd) at PX.Api.SyExportContext.ParseCommand(SYMappingField field) at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at PX.Api.SyExportContext..ctor(SYMapping mapping, IEnumerable1 fields, String[] providerFields, Dictionary2 viewFilters, Boolean breakOnError, Int32 start, Int32 count, Dictionary2 selectorViews, String rowFilterField) at PX.Api.ScreenUtils.Submit(String screenId, Command[] commands, SchemaMode schemaMode, PXGraph& graph, String& redirectContainerView, String& redirectScreen, Boolean mobile, Dictionary2 viewFilters) at PX.Api.Services.ScreenService.Submit(String id, IEnumerable1 commands, SchemaMode schemaMode, Boolean mobile, PXGraph& forceGraph, String& redirectContainerView, String& redirectScreen, Dictionary2 viewFilters) at PX.Api.Services.ScreenService.Submit(String id, IEnumerable`1 commands, SchemaMode schemaMode) at PX.Api.Soap.Screen.ScreenGate.Submit(Command[] commands) --- End of inner exception stack trace ---
But if I reduce code with single DocumentDetails as below:
$SO301000Submit->commands = array
(
$acumatica->prepareValue("SO", $SO301000GetSchema->OrderSummary->OrderType),
$SO301000GetSchema->Actions->Insert,
$acumatica->prepareValue("ACTIVESTAF", $SO301000GetSchema->OrderSummary->Customer),
$SO301000GetSchema->DocumentDetails->ServiceCommands->NewRow,
$acumatica->prepareValue("HQ", $SO301000GetSchema->DocumentDetails->Branch),
$acumatica->prepareValue("AALEGO500", $SO301000GetSchema->DocumentDetails->InventoryID),
$acumatica->prepareValue("WHOLESALE", $SO301000GetSchema->DocumentDetails->Warehouse, true),
$SO301000GetSchema->Actions->Save,
$SO301000GetSchema->OrderSummary->OrderNbr
);
$result = $acumatica->client->SO301000Submit($SO301000Submit);
Then, Everything is OK, a SalesOrder is created.
Here is function prepareValue:
public function prepareValue($value, $command, $needcommit = false, $ignore = false)
{
$value_command = new ObjectDocument\Value();
$value_command->Value = $value;
$value_command->LinkedCommand = $command;
if($needcommit) $value_command->Commit = true;
$soapvar = new \SoapVar($value_command, SOAP_ENC_OBJECT, "Value", "http://www.acumatica.com/generic/");
return $soapvar;
}
I don't know why? Please help me to explain this case.
