Sorry for the late reply. But just in case someone else comes across this thread like I did...
I created a Object for Interacting with SharePoint using CSOM API.
Using the Source
You can download the source at
GitHubGist, but you'll need to change a few things.
Reference CSOM DLLs
You'll need to add 2 DLLs (Microsoft.SharePoint.Client.Runtime.dll and Microsoft.SharePoint.Client.dll). You can download these 2 from
nuget.org packages, either "
Microsoft.SharePoint2013.CSOM" or "
Microsoft.SharePointOnline.CSOM" depending on your site and DLLs depending on your .Net Framework version. For me, I used SharePoint2013 and .Net4.0.
You can test the DLs are working by using a simple PowerShell script I posted to
GitHubGist.
There are 2 ways to update the references for the Blue Prism object:
1. Edit the source XML before importing. Update the below lines to the correct paths
XML:
...
<reference>\\MY\PATH\Microsoft.SharePoint.Client.Runtime.dll</reference>
<reference>\\MY\PATH\Microsoft.SharePoint.Client.dll</reference>
...
2. Import the object and in the first page, "Initialization", edit the Code Options -> External References
Testing
Each public action (TryExecuteQuery, Sign In, GetItems, UpdateItem, and DownloadFile) has a "RUN IN PLACE" section. You'll need to set each data input inside the block and edit the Multi Calc "Set Debug" with your test values. Then, set "RunInPlace" to True and Start!
JUST MAKE SURE YOU SET "RunInPlace" TO False BEFORE YOU SAVE!!!
A Few Improvement Ideas
- Action "Sign In" using ExecuteQuery to confirm the login was successful. However, this is not necessary. Instead, you can remove that and have the first real action (i.e. GetItems) called by a process be the first to call ExecuteQuery. This may lead to some confusing Exceptions, and a minimal performance improvement. So I opted to have "Sign In" exception mean the site or login are bad.
- When ExecuteQuery fails, action TryExecuteQuery just keeps trying even if the error is something trying again isn't going to fix - i.e. List does NOT exist. You can improve this by only continue to try for specific exceptions (e.g. "The remote server returned an error: (503) Server Unavailable.")
- TryExecuteQuery tracks how long ExecuteQuery takes to complete. You could track this or just remove the unnecessary code.
- UpdateItem is very basic. All values must be passed as a string.
- DateTimes should be in UTC format - e.g. 2018-07-27T08:00:00Z
- For Lookup or Person columns, you'll need to pass the Item's Id.
- Multi-Value columns CANNOT be updated in this implementation.
- Calling UpdateItem for multiple edits will be SLOW. Instead, you should add an UpdateItems action to update multiple items in a list, where each row in CollUpdates would be changes for an item, with columns "Id", "Field1", "Field2", ..., "FieldN".
- Action "DownloadFile" is very basic. The location is created or overwritten. You can optional add an Overwrite flag or automatically append " (2)".
- Testing is handled by having a "RunInPlace" section in each action. You could separate the code out by create a private "TEST <ACTION>" for each.