Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date filter in Microsoft Dynamics NAV webservice

When sending a filter to the webservice in php everything works fine, but when we need to sort on dates we encountered a problem. We need to get all the objects modified after a certain date.

In a page we have a date element, like so:

<xsd:element minOccurs="0" maxOccurs="1" name="Last_Date_Modified" type="xsd:date"/>

And we have tried the solution explained here on SO:

Dynamics Nav (Navision) webservice ReadMultiple date filter

But our date format is a bit different, ours looks like: 2013-01-01

In our filter, we have tried the following:

array(
    'Field' => 'Last_Date_Modified',
    'Criteria' => '20130101..'
)

And some other variations, but it doesn't return anything. If we leave it blank it returns everything. Does anyone have an idea as to what we can do? Would it help if we somehow stored the last_modified_date as a bigint like a unix timestamp?

like image 386
nielsstampe Avatar asked Mar 24 '23 23:03

nielsstampe


1 Answers

I've tested similar setup with SOAPui and here is what I've got:

Outgoing message:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:obj="urn:microsoft-dynamics-schemas/page/objlist">
<soapenv:Header/>
  <soapenv:Body>
       <obj:ReadMultiple>
         <obj:filter>
            <obj:Field>Date</obj:Field>
            <obj:Criteria>&gt;=01012013</obj:Criteria>
         </obj:filter>
         <obj:bookmarkKey></obj:bookmarkKey>
         <obj:setSize></obj:setSize>
      </obj:ReadMultiple>
   </soapenv:Body>
</soapenv:Envelope>

It results in correct response (with 3 records I have in my base changed since January) Also response is correct if I put 01012013.. or 01.01.2013.. or even 01/01/2013.. but error will be returned in response for 20130101..

In response this field have value like this <Date>2013-05-15</Date> which is incorrect format for my location though.

So your Nav server is waiting some other date format in your requests. Check Nav Server's CustomSettings.config file to see if it has <add key="ServicesCultureDefaultUserPersonalization" value="true"/> key. If you set it to "false" server will work in en-us date and number format.

Also check User Personalization table in Nav. If previous key set to true then Nav will try to use language settings defined for user in this table.

If nothing helps try SOAPui to find out if Nav response correct to direct message (see format above or feed soapui with your wsdl file).

like image 162
Mak Sim Avatar answered Apr 02 '23 05:04

Mak Sim