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.
Parameters
Connection
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. |
Example
- The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
- Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.
Description
This sample task demonstrates the use of sessions as well as Automate's 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 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.
<AMVARIABLE NAME="siteWorkflowInstanceID" VALUE="" />
<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="start_workflow" SESSION="SPSession1" WORKFLOWNAME="%siteWorkflowDataset.Name%" RESULTVARIABLE="siteWorkflowInstanceID" />
<AMFILESYSTEM ACTIVITY="write_file" FILE="c:\temp\execution_list">%siteWorkflowInstanceID%</AMFILESYSTEM>
<AMLOOP ACTIVITY="end" />
<AMSHAREPOINT ACTIVITY="end_session" SESSION="SPSession1" />