Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Friday, November 1, 2013

Data Driven Subscription using SharePoint List

In this article I will walk through the steps to create a data-driven subscription using a SharePoint list as a data source.  I'm using SSRS 2012 integrated in SharePoint 2010.

In the data driven subscription pane, choose a Description, set the Data Source Type to Microsoft SharePoint List, enter the url to the SharePoint site (obviously replacing the {SharepointDomain}/{SPSite}/ with the appropriate values, and entering in the credentials to be used by the subscription to access the list and execute the report.


The Next part is building the Query to be used.  I find it easiest to build the query by opening up SSRS Report Builder or Visual Studio and using the Query Designer inside of SSRS to help me.  In the example below, I've set up a SharePoint Data Source in my report called "SharePoint" which has the same same connection string as above:  http://{SharepointDomain}/{SPSite}


Opening up the Query Designer will take you to a page that looks like this.  In this example, I'm going to use the "subscription test" list for my data-driven values for the subscription.  I select the fields I need, and in this case, I put a filter in it to restrict my list to only list items that have a BeginDate less than 10/1/2013.  You may test your data by pressing the "Run Query" button as shown in the green box below.  This allow you to see exactly how the data will be returned.


Pressing "OK" takes me back to the original window and gives me my query syntax.

I copy the selected syntax and then go back to the data-driven subscription window and paste that code into the Query section.  Pressing the "Validate" button will check to make sure the syntax is correct.  At this point, the hard part is done...the rest of the subscription should be pretty straight forward.


The next page lets us wire up the parameters with the BeginDate and EndDate we retrieved from the SharePoint list query.


The next page lets us wire up the email address to the one in our SharePoint list.  It also requires us to specify a rendering type and subject.


The remainder of the subscription is setting the schedule just like any other subscription, so I won't provide any details on that screen.  Pressing "Finish" gives you a data driven subscription using a SharePoint list as your data source!

The hardest part for me is getting that query.  I've found that using the SSRS query designer to help me write the query is much easier than typing it all in myself.  The query designer is usually where I go to get the "stub" of my query, and then I manually change the bits and pieces in it that I need for the particular situation.  Good luck in your next SharePoint driven Data-Driven subscription!