views:

2201

answers:

4

I am trying to create a Data Source in SharePoint Designer that connects to a SharePoint List via XML Web Services. I have created the Data Source and connected to the list in question. I can view all the data using GetListItems, and I want to filter it using the query parameter.

The query parameter takes an XmlNode, and when I put this as the value I get an error:

<Query>
    <Where>
     <Eq>
      <FieldRef Name="Title" />
      <Value Type="Text">Foo</Value>
     </Eq>
    </Where>
</Query>

Of course, I have not entered any tabs or newlines, as I only have a one-line entry field in SharePoint Designer. I receive an error with this query:

The server returned a non-specific error when trying to get data from the data source. Check the format and content of your query and try again. If the problem persists, contact the server administrator.

I simply want to filter the list items resultset to be those with the Title field of "Foo". Can this be done in SharePoint Designer?


Update: escaping the < and > in this manner also fails:

&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;Title&quot; /&gt;&lt;Value Type=&quot;Text&quot;&gt;Foo&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;


Update: This appears to be a known issue with SoapDataSource components and SOAP calls. Apparently, they are over-encoding the <'s and >'s before they get submitted. The workaround given is to save the data source without a query parameter, and then to add it to the page and create a filter in the Common Data View Tasks dialog. I was able to get this to work using the following filter string:

[@ows_Title = 'Foo']

Unfortunately, this doesn't help me much as I am adding a Data View (showing the data) rather than a DataSource that I can use to point other controls to (like a drop-down list).

I'm still looking for a good solution on this that lets me place a datasource using SharePoint Designer.

+1  A: 

Hey! Did you XML encode the query? I believe you need to encode characters like <, > and " such that it is valid XML, e.g. :

&lt;Query&gt;&lt;Where&gt;

and

&lt;FieldRef Name=&quot;Title&quot; /&gt;
Peter Lillevold
that didn't work.
Nathan DeWitt
see my updates - apparently this is close to the problem, but the SoapDataSources munges the data. Any other thoughts?
Nathan DeWitt
Sorry, no, not yet at least. Haven't worked a lot with the SOAP data source.
Peter Lillevold
A: 

Having worked with the list Title field, it does not return values for me unless I used "Contains".

This may not fix your error however.

Nat
A: 

Did you find any solution. I am also facing the same problem

bug in sharepoint designer.
Nathan DeWitt
A: 

There is a bug in SharePoint Designer. You cannot pass a Query object to a SOAPDataSource like this - the XML gets overencoded. Nothing you can do to fix it, except use Visual Studio.

I'll let you know if there's ever a hotfix available.

If anyone wants to quote this answer in a new answer, I'll accept that answer.

Nathan DeWitt