1

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 . "&nbsp;" . $rec->Description."<br>";
        }
    } else {
        echo $resultSet->No . "&nbsp;" . $resultSet->Description."<br>";
    }
} catch (Exception $error) {
    echo "<hr><b>ERROR: SoapException:</b> [" . $error . "]<hr>";
    echo "<pre>" . htmlentities(print_r($service->__getLastRequest(),1)) . "</pre>";
}
Mike Willis
  • 1,493
  • 15
  • 30
  • It's a soap, don't think you can do that. – Mak Sim Nov 15 '16 at 18:37
  • @MakSim It looks like you're right - after submitting this question I found Microsoft's documentation for `ReadMultiple` and it doesn't have any details as far as selecting specific columns. Next step is to make custom Pages and/or Queries and expose them as Web Services instead. – Mike Willis Nov 15 '16 at 19:27
  • 1
    You always ask the NAV Developer "on the other side" to reduce the number of column if it has serious performance impact – azatoth Nov 16 '16 at 11:53

0 Answers0