2017-01-25 60 views
0

我試圖通過acumatica上的Web服務保存客戶數據。但我收到此錯誤:如何使用PHP通過Acumatica ERP上的Web服務保存數據

SoapFault Object ( [message:protected] => 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.a(SYMappingField A_0) at System.Linq.Enumerable.WhereSelectArrayIterator 2.MoveNext() at System.Collections.Generic.List 1..ctor(IEnumerable 1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable 1 source) at PX.Api.SyExportContext..ctor(SYMapping mapping, IEnumerable 1 fields, String[] providerFields, Dictionary 2 viewFilters, Boolean breakOnError, Int32 start, Int32 count, LinkedSelectorViews selectorViews, String rowFilterField) at PX.Api.ScreenUtils.Submit(String screenId, Command[] commands, SchemaMode schemaMode, PXGraph& graph, String& redirectContainerView, String& redirectScreen, Boolean mobile, Dictionary 2 viewFilters) at PX.Api.Services.ScreenService.Submit(String id, IEnumerable 1 commands, SchemaMode schemaMode, Boolean mobile, PXGraph& forceGraph, String& redirectContainerView, String& redirectScreen, Dictionary 2 viewFilters) at PX.Api.Services.ScreenService.Submit(String id, IEnumerable 1 commands, SchemaMode schemaMode) at PX.Api.Soap.Screen.ScreenGate.Submit(Command[] commands)

下面是我的代碼:

require_once('AcumaticaGate.php'); 

$client = new AcumaticaGate("username", "password",'AR303000','http://host/acumatica/Soap'); 

$schema   = $client->Schema->GetSchemaResult; 

$customer   = $schema->CustomerSummary->CustomerID; 
$customer_name  = $schema->CustomerSummary->CustomerName; 
$customer_status = $schema->CustomerSummary->Status; 
$customer_class  = $schema->GeneralInfoFinancialSettings->CustomerClass; 
$cycle_id   = $schema->GeneralInfoFinancialSettings->StatementCycleID; 
$credit    = $schema->GeneralInfoCreditVerificationRules->RemainingCreditLimit; 
$country   = $schema->GeneralInfoMainAddress->Country; 
$sales_account  = $schema->GLAccounts->SalesAccount; 
$cash_discount  = $schema->GLAccountsCashDiscountAccount->CashDiscountAccount; 

$command = array(); 
array_push($command, $client->PrepareValue('101923', $schema->CustomerSummary->CustomerID)); 
array_push($command, $client->PrepareValue('Richard Chambula Test Acc', $customer_name)); 
array_push($command, $client->PrepareValue('On Hold', $customer_status)); 
array_push($command, $client->PrepareValue('DEFAULT', $customer_class)); 
array_push($command, $client->PrepareValue('EOM', $cycle_id)); 
array_push($command, $client->PrepareValue('Disabled', $credit)); 
array_push($command, $client->PrepareValue('NA', $country)); 
array_push($command, $client->PrepareValue('5011', $sales_account)); 
array_push($command, $client->PrepareValue('8302', $cash_discount)); 

array_push($command, $schema->Actions->Save); 
$submit = new Submit(); 
$submit->commands = $command; 

try 
{ 
    $submit_result = $client->Client->Submit($submit); 
} 
catch(Exception $e) 
{ 
    echo "<PRE>"; 
    print_r($e); 
} 
+0

你在使用Acumatica 5.3還是6.0? – RuslanDev

+0

我正在Acumatica 5.3上工作 –

回答

0

您應該將狀態設置爲在保持「H」。這是一個字符字段。 Acumatica的大部分下拉菜單都是價值和描述符字段的組合。

相關問題