Note that there are some explanatory texts on larger screens.

plurals
  1. POSharepoint Filter for List Items(GetListItems)
    primarykey
    data
    text
    <p>I'm attempting to get a set of list items from sharepoint via the WebService. I want to query a small subset of items to be returned. My SOAP packet appears to be ordered properly, however, it still appears that the service is ignoring my set filter(query). Any ideas why this would still be happening?</p> <pre><code>&lt;SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;SOAP-ENV:Header/&gt; &lt;ns0:Body&gt; &lt;ns1:GetListItems&gt; &lt;ns1:listName&gt;MyCalendar&lt;/ns1:listName&gt; &lt;query&gt; &lt;Query&gt; &lt;Where&gt; &lt;Eq&gt; &lt;FieldRef Name="EventDate"/&gt; &lt;Value Type="DateTime"&gt;[Now+2Minute(s)]&lt;/Value&gt; &lt;/Eq&gt; &lt;/Where&gt; &lt;/Query&gt; &lt;/query&gt; &lt;/ns1:GetListItems&gt; &lt;/ns0:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>and here is the python suds code that i used to generate this soap:</p> <pre><code>Query = Element('Query') where = Element('Where') eq = Element('Eq') eq.append(Element('FieldRef').append(Attribute('Name', 'EventDate'))) vt = Element('Value').append(Attribute('Type', 'DateTime')).setText('[Now+2Minute(s)]') eq.append(vt) where.append(eq) Query.append(where) query = Element('query') query.append(Query) </code></pre> <p>EDIT:</p> <p>Here is the proper soap packet and suds code for what eventually worked for me. I have some strange requirements around the filter, but i'll go ahead and post as is so that others may learn from this.</p> <pre><code>&lt;SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;SOAP-ENV:Header/&gt; &lt;ns0:Body&gt; &lt;ns1:GetListItems&gt; &lt;ns1:listName&gt;Economic Event Calendar&lt;/ns1:listName&gt; &lt;ns1:query&gt; &lt;Query&gt; &lt;Where&gt; &lt;And&gt; &lt;Geq&gt; &lt;FieldRef Name="EventDate"/&gt; &lt;Value IncludeTimeValue="TRUE" Type="DateTime"&gt;2010-08-12T07:38:00&lt;/Value&gt; &lt;/Geq&gt; &lt;Lt&gt; &lt;FieldRef Name="EventDate"/&gt; &lt;Value IncludeTimeValue="TRUE" Type="DateTime"&gt;2010-08-12T07:39:00&lt;/Value&gt; &lt;/Lt&gt; &lt;/And&gt; &lt;/Where&gt; &lt;/Query&gt; &lt;/ns1:query&gt; &lt;ns1:rowLimit&gt;5&lt;/ns1:rowLimit&gt; &lt;viewFields&gt; &lt;FieldRef Name="Description"/&gt; &lt;FieldRef Name="EventDate"/&gt; &lt;/viewFields&gt; &lt;/ns1:GetListItems&gt; &lt;/ns0:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>and the python/suds code that got me here:</p> <pre><code>#craft our XML Query = Element('Query') where = Element('Where') And = Element('And') geq = Element('Geq') geq.append(Element('FieldRef').append(Attribute('Name', 'EventDate'))) vt = Element('Value').append(Attribute('IncludeTimeValue', 'TRUE')) vt.append(Attribute('Type', 'DateTime')).setText(convert_dt('now +' + str(alertBefore) + ' minutes', '%Y-%m-%dT%H:%M:00' )) lt = Element('Lt') lt.append(Element('FieldRef').append(Attribute('Name', 'EventDate'))) vt2 = Element('Value').append(Attribute('IncludeTimeValue', 'TRUE')) vt2.append(Attribute('Type', 'DateTime')).setText(convert_dt('now +' + str((alertBefore + 1)) + ' minutes', '%Y-%m-%dT%H:%M:00' )) #viewFields fragment, only show the Description and EventDate for returned rows viewFields = Element('viewFields') viewFields.append(Element('FieldRef').append(Attribute('Name','Description'))) viewFields.append(Element('FieldRef').append(Attribute('Name','EventDate'))) #pack all the XML fragments geq.append(vt) lt.append(vt2) where.append(And) And.append(geq) And.append(lt) Query.append(where) query = Element('ns1:query') query.append(Query) #issue the query results = c_lists.service.GetListItems(SPCal, None, query, None, 5, viewFields, None) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload