akrasheninnikov

Query XML: Uses and limitations of URL Protocol queries from SharePoint Lists

Blog Post created by akrasheninnikov Expert on Jan 21, 2015

Although somewhat non-trendy nowadays, XML processing is still very much relevant in the SharePoint space. Nintex Workflow is very kind to offer us actions to make Web request or Call web service.

 

It's not obvious, but the Query XML action can do both a GET HTTP request to retrieve some XML data and produce multiple XPath and XSLT outputs in a single action.

 

The native SharePoint owssvr.dll endpoint that exposes the URL Protocol comes in handy when all you need is some selection of data from a SharePoint list or library. It lets you easily filter the data you want both vertically and horizontally: by some Field equals Value condition and a selection of Fields to output (without the clutter that a Lists.asmx web service call necessarily returns).

 

So imagine you only need the people who have pending tasks assigned to them, then you need and format to say:

Tell me, in the XML format, (Cmd=Display&XMLDATA=TRUE) who (Query=AssignedTo) has tasks in this list (List={GUID}, for example from a link on Site settings - Site lists and libraries) that are not started (FilterField1=Status&FilterValue1=Not Started).

 

Note that

  1. We need to provide the Internal names of the fields we query or filter on, spaces are replaced with _x0020_ and international characters may also be encoded this way. Fields in the query can be joined either by space or plus separator: Query=ID+Title or  Query=Editor Modified.
  2. We can ask for all fields with Query=*, but that defeats one of the benefits.
  3. We can filter on multiple fields at once, numbering them accordingly (FilterFieldN=...&FilterValueN=...), implicitly disjuncting them with AND logical operator (no need to specify it in the query).
  4. We cannot use operators other than "equals" or conjunct conditions with OR.
  5. We cannot use the FilterName=ID&FilterMultiValue=1;2;3 construct to select multiple items

 

Here's a sample URL this could sum up to:

{WorkflowContext:Current WEB URL}/_vti_bin/owssvr.dll?Cmd=Display&XMLDATA=TRUE

&List={Common:ListName}

&Query=ID+Title+SomeOtherFieldYouNeed

&FilterField1={WorkflowVariable:The internal name of the field, such as Title or ID orSome_x0020_Field}

&FilterValue1={WorkflowVariable:What you search for}.

Hopefully, you'll find this helpful.

Outcomes