I had used PHP Client library for Exact Online.
I need to store the record, based on the condition if it exists or not. Since records are saving successfully. But unfortunately records are not updating.
$customer = [
'address' => 'No.22/N, 91 Cross, XYZ Street, ABC Road',
'address2' => 'DEF',
'city' => 'GHI',
'customerid' => '999',
'country' => 'DE',
'name' => 'Nishanth',
'zipcode' => '123456'
];
// Create a new account
$account->AddressLine1 = $customer['address'];
$account->AddressLine2 = $customer['address2'];
$account->City = $customer['city'];
$account->Code = $customer['customerid'];
$account->Country = $customer['country'];
$account->IsSales = 'true';
$account->Name = $customer['name'];
$account->Postcode = $customer['zipcode'];
$account->Email = '[email protected]';
$account->Status = 'C';
From the above piece of code, based on the condition the record needs to be updated or saved from the below coding snippets. Followed two approaches:
I Approach:
if($AccInfo)
{ // Update
$AccInfo->AddressLine1 = $customer['address'];
$AccInfo->AddressLine2 = $customer['address2'];
$AccInfo->City = $customer['city'];
$updateAcc = $AccInfo->update();
}
else
{ // Save
$savedAcc = $Accounts->save();
}
Result:
Warning: Attempt to assign property 'AddressLine1' of non-object in E:\xampp\htdocs\exact-php-client-master\example\example.php on line 506
Warning: Attempt to assign property 'AddressLine2' of non-object in E:\xampp\htdocs\exact-php-client-master\example\example.php on line 507
Warning: Attempt to assign property 'City' of non-object in E:\xampp\htdocs\exact-php-client-master\example\example.php on line 508
Fatal error: Uncaught Error: Call to a member function update() on array in E:\xampp\htdocs\exact-php-client-master\example\example.php:510 Stack trace: #0 {main} thrown in E:\..\..\exact-php-client-master\example\example.php on line 510
II Approach:
if($AccInfo)
{ // Update
$updateAcc = $Accounts->update();
}
else
{ // Save
$savedAcc = $Accounts->save();
}
Result:
Picqer\Financials\Exact\ApiException : Error 400: Bad Request - Error in query syntax.
How should we need to update the records to Exact Online Dashboard?
Finally I solved the issue by writing custom methods
I had written my own methods from
..\src\Picqer\Financials\Exact\Persistance\Storable.php
For any one who knows exactly how to update to an ExactOnline. You are always welcome to answer to the posted question via built-In function call known as
update()
.