Automating SharePoint Downloads in 3 Easy Steps

by Ronak Patel, in SharePoint Automation, posted 12/14/10

Overview

Microsoft SharePoint collaboration software is emerging as one of the more powerful tools for companies that need to design and implement enterprise-scale solutions to meet business-critical needs such as managing content, administering business processes and streamlining how people find and share information across the network. The SharePoint system is composed of a full range of applications and tools that allow document management, workflow design and collaboration, which helps teams stay connected and productive by providing easy access to the people, documents and information that can help in decision making and getting work done.  

With the use of AutoMate's SharePoint automation activities, organizations have the power to automate the creation, management and implementation of SharePoint sites that are discoverable throughout the organization. By further streamlining and automating SharePoint processes, a company's resources can be allocated to other areas, which can lead to reduced costs and greater operational efficiency. SharePoint action works with 2010, 2007 and 2003 server.

AutoMate and SharePoint

AutoMate uses the Client Object Model to communicate with SharePoint 2010 and web services to communicate with SharePoint 2007 and 2003.  For all versions of SharePoint, users are able to manage lists, as well as list items, documents and sites. SharePoint groups and roles, however, are only manageable with SharePoint 2010 server.

SharePoint image

In this tech article we will explore how you can use AutoMate to download a single file (document) stored in a “Shared Documents” library of SharePoint.

Step 1

Drag SharePoint action and select “Create Session” activity.

SharePoint_create

You need to provide the SharePoint site URL and the proper credentials to connect to the SharePoint server.

Optionally, the Http Proxy settings can also be provided.

Step 2

Drag the SharePoint action and select the “Download file” activity. In order to download a specific file you need to provide the server relative URL. In the example below, the URL site is http://server/my/personal/Team so the server relative URL would be: /my/personal/Team/ Library Name/File Name (/my/personal/Team/Shared Documents/Data.txt). If you have a sub folder inside the library, the URL would look something like this: /my/personal/Team/Library Name/Sub Folder Name/ File Name (/my/personal/Team/Shared Documents/Dev/Log.txt).

SharePoint_download

Step 3

Drag the SharePoint action and select “End session” activity.

Task:

   <AMSHAREPOINT ACTIVITY="create_session" SITE="http://server/my/personal/Team" AUTHTYPE="Basic" USERNAME="administrator" PASSWORD="password" DOMAIN="winserv08r2" />

   <AMSHAREPOINT URL="/my/personal/Team/Shared Documents/Data.txt" DESTINATION="C:\Logs\data.txt" PROVIDER="session_based" />

   <AMSHAREPOINT ACTIVITY="end_session" />

You can also provide the same server setting in the “Download file” activity and achieve the same result with one step. We recommend that users use session when they need to perform multiple transactions with the SharePoint server.

How to download all the file(s) from the “Shared Documents” library?

Use SharePoint activity “Get files” to get the dataset of all the file(s) available in the “Shared Documents” library. Then loop through that dataset and use dataset fields FileRef and FileLeafRef to download one file at a time.

FileRef : provides server relative URL of the file (document)

FileLeafRef: provides file (document) name

The default query provided in “Get file” activity will retrieve all the file(s) within the library recursively. You can also specify a custom CAML query in order to retrieve some specific file(s).

Task:

   <AMSHAREPOINT ACTIVITY="create_session" SITE="http://server/my/personal/Team" AUTHTYPE="Basic" USERNAME="administrator" PASSWORD="password" DOMAIN="winserv08r2" />

<AMSHAREPOINT ACTIVITY="get_files" LIBRARY="Shared Documents" RESULTDATASET="test" PROVIDER="session_based" />

<AMLOOP TYPE="DATASET" DATASET="test">

   <AMSHAREPOINT URL="%test.FileRef%" DESTINATION="C:\Logs\%test.FileLeafRef%" OVERWRITE="yes" PROVIDER="session_based" />

</AMLOOP>

<AMSHAREPOINT ACTIVITY="end_session" />

Conclusion

AutoMate is a powerful software platform that primarily focuses on supplying a complete, all-in-one system for the development, deployment, management and automation of simple to elaborate business and IT processes. Its intuitive, drag-and-drop based graphical interface provides businesses of all sizes with a true rapid-development platform for streamlining business operations executed on the desktop that requires no programming knowledge to use and maintain. With the addition of 40 different activities related to SharePoint, integrating SharePoint and its data into automation routine becomes effortless. Users can achieve uploading/downloading SharePoint documents or retrieving/adding list-items to SharePoint list with simple drag-and-drop steps.