4

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?

1 Answer 1

7

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).

5
  • I have tried both, and I'm getting a faultcode: 'is not a valid date'. Commented May 15, 2013 at 8:50
  • More info required. I don't know how php works with web services. It would help if you post soap message that is send to Nav and soap response from Nav. If you use some kind of framework which hides messages from you, use sniffer to catch them.
    – Mak Sim
    Commented May 15, 2013 at 11:08
  • I appreciate your help. I'm using Freddy's approach to connecting through PHP, as described here: blogs.msdn.com/b/freddyk/archive/2010/01/19/… Commented May 15, 2013 at 11:25
  • I actually got it working using 'Criteria' => '>=15/05/2013' even though the elements have this format [Last_Date_Modified] => 2013-05-15. Seems to be working as it should! I'm baffled! Commented May 15, 2013 at 11:26
  • You can try to play with settings I've mentioned in edited answer.
    – Mak Sim
    Commented May 15, 2013 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.