I'm using PHP to connect to Microsoft Dynamics Nav (Navision) Web Services 2016. Authentication (NTLM) is working fine, and I can get data. So far I'm testing the Item page and the Item List page.
I can easily filter which items I want to retrieve, but now I would like to filter the columns I retrieve as well. Is there a way to do this? Basically the equivalent of a MySQL SELECT this, that, theOther...
statement instead of SELECT *...
Here's some of the relevant code, I used this guide as a starting point.
try {
$pageURL = $baseURL . "ItemList";
$service = new NTLMSoapClient($pageURL);
// this filter says to get all items. I could change Criteria to an item number to get just that item.
$params = array('filter'=>array( array('Field'=>'No', 'Criteria'=>'*') ), 'setSize'=>20);
$result = $service->ReadMultiple($params);
$resultSet = $result->ReadMultiple_Result->ItemList;
if (is_array($resultSet)) {
foreach($resultSet as $rec) {
echo $rec->No . " " . $rec->Description."<br>";
}
} else {
echo $resultSet->No . " " . $resultSet->Description."<br>";
}
} catch (Exception $error) {
echo "<hr><b>ERROR: SoapException:</b> [" . $error . "]<hr>";
echo "<pre>" . htmlentities(print_r($service->__getLastRequest(),1)) . "</pre>";
}