Opening SharePoint Files in Blue Prism

atravalent

New Member
How are you guys opening Excel files stored in SharePoint? We have a standard object for opening Excel files and when we put in the local network path for the SharePoint file it will not open consistently. If we have already accessed the file on that computer it will open no problem, however, when sending the process to a virtual machine, it will error and not access the file.
 

owns

New Member
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.
    1. DateTimes should be in UTC format - e.g. 2018-07-27T08:00:00Z
    2. For Lookup or Person columns, you'll need to pass the Item's Id.
    3. 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.
 
Last edited:

jreddy

New Member
Hi @owns

thanks for sharing this VBO! Can I also upload files to SharePoint using this VBO? UpdateItem doesn't seem to be meant for that. Can you please advise me on the matter?
 

Khushbu

New Member
I am getting below error:
Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
 

Khushbu

New Member
I am getting below error:
Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
 

VJR

Well-Known Member
Could not load file or assembly 'Microsoft.SharePoint.Client.....The system cannot find the file specified.
Hi Khushbu

At least from the above message it looks like this dll (Microsoft.SharePoint.Client.dll) is not present on your machine or not yet registered.
 

owns

New Member
You'll want to create a new method and use a scripting block similar to the other actions - I just googled "sharepoint csom upload file" and found several samples.
I have not uploaded a file yet. If I do end up expanding the object, I'll update it here.
 

ashibm

New Member
I am getting below error:
Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

Did you find a solution?
 
Top