SharePoint - End Session

Declaration

<AMSHAREPOINT ACTIVITY="end_session" SESSION="text" />

Description: Ends a session previously created using the Create Session activity.

Practical Usage

SharePoint operations must be linked to a specific session. This activity is often used at the end of a task to end a specific session after all operations have been completed.

Connection Parameters

Property

Type

Required

Default

Markup

Description

Session

Text

Yes

SharePointSession1

SESSION="mySession1"

The session name end. Multiple sessions can exist within a single task allowing several SharePoint operations to be automated simultaneously.

NOTE: Use the Create Session activity to create a new session.

Description: This sample task demonstrates the use of sessions as well as ability to start all workflows that exist in a given site. A Get workflows activity is used to retrieve the workflows from a particular site and populates a dataset with results. The dataset is then looped. During each iteration, a Start workflow activity starts the next workflow on the list . In addition, each running workflow's instance ID is retrieved and written to a file for reporting or auditing purposes.

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

<AMVARIABLE NAME="siteWorkflowInstanceID" />
<AMSHAREPOINT ACTIVITY="create_session" 
SITE="https://netauto.sharepoint.com/sites/test" VERSION="sharepointonline" 
USERNAME="SharePoint_Master@networkautomation.com" PASSWORD="AM4gM61nOkRPtC4LT0m+2C9UykOt9MCt8BEaME" SESSION="SPSession1" />
<AMSHAREPOINT ACTIVITY="get_workflows" SESSION="SPSession1" RESULTDATASET="siteWorkflowDataset" />
<AMLOOP ACTIVITY="dataset" DATASET="siteWorkflowDataset">
<AMSHAREPOINT ACTIVITY="start_workflow" SESSION="SPSession1" WORKFLOWNAME="%siteWorkflowDataset.Name%" 
RESULTVARIABLE="siteWorkflowInstanceID" />
<AMFILESYSTEM ACTIVITY="write_file" 
FILE="c:\temp\execution_list">%siteWorkflowInstanceID%</AMFILESYSTEM>
</AMLOOP>
<AMSHAREPOINT ACTIVITY="end_session" SESSION="SPSession1" />