• vadim@workflowexcellence.com
  • Utah, United States

Nintex Workflow – Get Recurring Events UDA

This comes up fairly regularly, so it was a good time to post about this.  Especially after an exciting and inspiring Nintex InspireX User Conference.

I’m talking about the ability for a workflow to query a SharePoint calendar, and get recurring events.

There was a lot of searching online to find a way to create this User Defined Action.  But, finally it’s done.  The aim of this UDA, is to give a Workflow designer, the ability to pass in SharePoint Calendar name and how long we period we want to look at.  It could be Today, Week, Month or Year.  The output of this UDA, will be 4 collections.  Event Title, Location, Start DateTime and End DateTime.

How does this work?

This all revolves around an awesome web service that SharePoint exposes, called Lists.asmx. Most specifically, the GetListItems web method. 

The UDA looks like this:

Here are the parameters of the UDA:

The UDA in this post uses a Call Web Service action.  In most cases, it’s a great action to use as it tells you what fields need to be filled in in a cool user interface.  But it some cases, such as this one, the user interface doesn’t cut it, and you need to get into the SOAP Editor Mode.  Now, you can put the SOAP packet together, even though it gives you a great starting off point.  Here’s what the GetListItems web method call looks like :

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/sharepoint/soap/">
  <soap:Header>
  </soap:Header>
  <soap:Body>
    <m:GetListItems>
      <m:listName>{WorkflowVariable:CalendarName}</m:listName>
      <m:viewName>
      </m:viewName>
      <m:query>
        <Query>
          <Where>
            <DateRangesOverlap>
              <FieldRef Name="EventDate" />
              <FieldRef Name="EndDate" />
              <FieldRef Name="RecurrenceID" />
              <Value Type="DateTime">
                <Today />
              </Value>
            </DateRangesOverlap>
          </Where>
        </Query>
      </m:query>
      <m:viewFields>
      </m:viewFields>
      <m:rowLimit>
      </m:rowLimit>
      <m:queryOptions>
        <QueryOptions>
          <ExpandRecurrence>TRUE</ExpandRecurrence>
        </QueryOptions>
      </m:queryOptions>
      <m:webID>
      </m:webID>
    </m:GetListItems>
  </soap:Body>
</soap:Envelope>

I’ve highlighted a few things in the SOAP XML packet.  But really, the important things are the Today node.  This can be Week, Month or Year also.  Finally, in the QueryOption, there’s a node called ExpandRecurrence, which is set to TRUE.

Watch the video above, as I mention a few things I encountered when getting this to work.  Nothing crazy, but if you’re just learning about this web method, it’s nice to know about some gotchas.

The Workflow looks like this:

After the usage of the UDA, we are going through all the event collections.  This is really just for debugging, but I’m sure you’ll find a real business case for this.

Downloads

Nintex Workflow 2013

Download the files

Leave a Reply

Your email address will not be published. Required fields are marked *