Date filter in Microsoft Dynamics NAV webservice

半城伤御伤魂 提交于 2019-12-19 10:19:23

问题


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:


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



来源:https://stackoverflow.com/questions/16542364/date-filter-in-microsoft-dynamics-nav-webservice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!