0
votes

I am trying to save customer data via a web service on acumatica. But I am getting this error:

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.WhereSelectArrayIterator2.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, LinkedSelectorViews 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, IEnumerable1 commands, SchemaMode schemaMode) at PX.Api.Soap.Screen.ScreenGate.Submit(Command[] commands)

Below is my code:

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);
}
1
Are you working with Acumatica 5.3 or 6.0? - RuslanDev
I am working on Acumatica 5.3 - Richard Tonata

1 Answers

0
votes

You should set your status to 'H' for On Hold. It's a one char field. Most of the drop downs in Acumatica are a combination of value and descriptor fields.