Introduction
This article contains some basic examples of how to efficiently pull client data via the API.
Example 1
Retrieving client code, active flag and external debtor code for all web-published clients in one API call:
$result = $client->QueryAdditionalData(array( 'token' => $token, 'entityName' => 'Client', 'filterCriteria' => array( array( 'Field' => 'WebPublishFlag', 'Operator' => 'Equals', 'Value' => 'Y' ), ), 'returnFields' => array( array( 'Field' => 'ClientCode', ), array( 'Field' => 'ActiveFlag', ), array( 'Field' => 'ExternalDebtorCode', ), ) ));
Example 2
If you have a list of client codes you can get these fields for all clients with those codes in one call (or you could make a call per 50 clients etc) by making use of the any_filter_criteria option:
$result = $client->QueryAdditionalData(array( 'token' => $token, 'entityName' => 'Client', 'filterCriteria' => array( array( 'Field' => 'ClientCode', 'Operator' => 'Equals', 'Value' => '00590' ), array( 'Field' => 'ClientCode', 'Operator' => 'Equals', 'Value' => '00010' ), ), 'returnFields' => array( array( 'Field' => 'ClientCode', ), array( 'Field' => 'ActiveFlag', ), array( 'Field' => 'ExternalDebtorCode', ), ), 'options' => 'any_filter_criteria', ));
Example 3
Another way to implement regular sync while minimising the number of API calls is to get the details for all clients that have been modified since the last time you complete a sync:
$result = $client->QueryAdditionalData(array( 'token' => $token, 'entityName' => 'Client', 'filterCriteria' => array( array( 'Field' => 'ModifiedDate', 'Operator' => 'GreaterThanOrEqualTo', 'Value' => '2020-02-01 14:30:00' ), ), 'returnFields' => array( array( 'Field' => 'ClientCode', ), array( 'Field' => 'ActiveFlag', ), array( 'Field' => 'ExternalDebtorCode', ), array( 'Field' => 'ModifiedDate', ), ), ));