another technical blog...technically

Friday, August 25, 2017

O365 team site external user issue

I love O365 because it enables (power) users to do whatever they want to. I saw people developing their own assets using Flow and Power Apps and share them across market units.
Moreover Team site evolved in something which is more user friendly, and people are able to create their own site for a project (mixing together Planner, SharePoint Online, OneDrive and other stuff) in order to include also external users and make them able to interact with them: this is common if the customer outsources lots of activities.
Lately i found a curious problem, i created a SharePoint group with also external users, after that i broke inheritance on some document library (customer does not want to allow everyone to see what's happening on the project site) and assign some custom permission to external users.
So i created custom groups and added people, and, even if O365 gave me no error, no user was added. I kept trying without results and, because i've to go on vacancy, i had to solve the problem easily.
At first time i read this link and then this other one by Microsoft and i set up this value as site collection sharing capability one.
Set-SPOSite -Identity https://contoso.sharepoint.com/sites/site1 -SharingCapability ExternalUserSharingOnly
I noticed that, if you face that problem, even if you are not able to accomplish the task using UI, you can do it using PowerShell, so, i created this small script that can help you to save your vacancy.
I have not found the root cause, meantime, have fun with this.
Before reading the other script, i wanna thank you Simone Anzaldi (Big up) who helped me with this problem.
# PARAM
$URL = "https://varrocorp.sharepoint.com/sites/Test"  

$USR = "admin@varrocorp.it"  
$PWD = "UsernamePassword"

$GROUPNAME = "Da Group"
$EXTERNALUSERNAME = "user@externaldomain.com"


# Import some libraries
Import-Module MSOnline
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($URL)  

# Just converting plain text to secure string
$pwd = ConvertTo-SecureString -String $PWD -AsPlainText -Force
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($USR, $PWD)  
$ctx.credentials = $creds   

# Get root site details   
$web = $ctx.Site.RootWeb 

# Gets all site groups   
$groups = $web.SiteGroups
$ctx.Load($groups)  
$ctx.ExecuteQuery()  

# Get user info of the external user
$userInfo = $web.EnsureUser($EXTERNALUSERNAME)  
$ctx.Load($userInfo)  

# Get group by name and add the user
$group = $web.SiteGroups.GetByName($GROUPNAME) 
$addUser = $group.Users.AddUser($userInfo)  
$ctx.Load($addUser)  
$ctx.ExecuteQuery()  

# Paranoid check
$group = $web.SiteGroups.GetByName($GROUPNAME) 
$users = $group.Users  
$ctx.Load($users)  
$ctx.ExecuteQuery()  
foreach($user in $users){  
    Write-Host " " $user.Title  
}  
Share:

Saturday, May 20, 2017

BluePrism attended processes? Why not?

One of cons customers find out on Blue Prism, is the fact attended processes are not supported out-of-the-box.
Well this is not so true because you can play with BP in order to someway create attended processes.
If you are an enterprise and you don't use SharePoint, please raise your hand... i see no one.
So we can use SharePoint (or Office 365 as well) to interact with BP with a tiny additional effort. Moreover, if we create a solution using NCSSs (No Code Sandbox Solutions), we can do the work fast and without great impacts on pre-existing solutions.
I will refer to the producer-consumer model during this article, so, if you haven't read it... read it :-) http://valeriovalrosso.blogspot.it/2017/04/a-simple-blue-prism-multi-robot-example.html

 

Solution 1

There are 2 possible scenarios from the real world:
  1. Robot polls for new item to process directly from a SharePoint list
  2. Call the robot as a web service from SharePoint and consume the service
 Scenario 1
 Scenario 1
A typical real world scenario 1 example is the one above:
  • User does something on list items
  • User interacts with the list items through the workflow
  • Robot polls continuosly on the list in order to find items to process (in this case also processed by the workflow) and put them into a queue
  • Robot consumes items and writes back something to the list item about the automation results
An important advice is to write on the new item list the fields: "Robot Machine Name" and "Robot Machine User". This will be a useful information during debugging sessions because, in a multi-robot scenario, you will use more than a robot that will do the action on the SharePoint portal, and will make debug sessions easier.

Solution 2

The second scenario, here below, calls directly the robot from the workflow (or from JavaScript or other techniques, it depends on what you wanna do).
  Scenario 2
 Scenario 2
To do so, you need to expose the process and create some code in order to call the robot web service.
In my example i created only one process which does nothing for 1 minute, here the wsdl BP created for me, and a small piece of code below, which shows how to call the BP web service.
The wsdl BP produces for you

Consuming using C#

You have to remember that web services aren't exposed on all resources, so you'd better to design which machine (in a multirobot scenario) is the "producer machine", and maybe use a configuration list on SharePoint to configure the value dinamically.
Moreover could be a good idea to split the producer-consumer model, exposing only the producer, leaving the consumer in the loop.
Since multiple invoked processes could be executed at the same time (as you can see below), think about just using the producer to fill the queue with the information from SharePoint and avoid the full automation when the service is called, because it could became a dangerous bottleneck and you will have to deal with concurrency on the same machine.

Concurrency
So the message is: even if you can play with different technologies, mind you have to think in a multi-thread way now.

Conclusions

Like everything in the world, different approaches have pros and cons
Scenarios PROs CONs
Scenario 1 - Easier support to multiple robots
- Scalable
- Pay attention to polling
Scenario 2 - You can put an item in queue and give an immediate response - Binding to a single "root" producer machine

An that's all my friends.

Thursday, April 27, 2017

A simple Blue Prism multi-robot example

I will talk about one of the most interesting things I've seen on Blue Prism, we're talking about multi-robot and task concurrency.
As you already know, to build a process on Blue Prism, you have to use one or more queues, which are built to manage concurrency between multiple robots.
The question is: how to optimize concurrency among multiple robots?
The answer is in the process design.
Let's think about the typical producer-consumer model we deal with when we tipically work with multi-thread and let's imagine three robots up and running.
Like you see i defined a main flow which references two subprocesses: producer and consumer.
The main flow is a infinite loop that will be started from the scheduler, to stop the loop you can use a decision stage that checks a finish time, written on an environment variable.
The first subprocess is the producer and populates the work queue.
It's kinda best practice to put a environment lock before the producer starts in order to have just a robot at a time working on the producer process.
This is due to the fact we want to avoid multiple robot to do concurrently the queue population process and not so useful checks on already existing queue items.
Consumer it's a simple loop that iterates on the queue until the queue itself it's empty, no lock here, because Blue Prism deals with concurrency and locks the work item itself.
I know it's a very simple process but this is the baseline for other stuff, right now i'm working on a process which has something like 2 producers and 3 consumers, playing with environment locks on producer processes i can optimize concurrent robot performances.
I heard someone who preferred to pre-assign work item to different robot but i think this is not a good idea, this is because you cannot be sure a single work item requires the same amount of time.
For example, in one of our project we had some work item requiring up to 7 hours of robot effort.
Item name Assigned to Avg duration
1 Robot 1 7h
2 Robot 2 1h
3 Robot 3 1h
4 Robot 1 6h
5 Robot 2 2h
6 Robot 3 3h

If you work the items with pre assignation you will have this work duration
Robot 1: 13h
Robot 2:   3h
Robot 3:   4h

This means you'll have very low efficiency on Robot 2 and Robot 3. Applying the multi-robot model you'll have something like this
Robot 1: 7h (1)
Robot 2: 1h (2) + 6h (4)
Robot 3: 1h (3) + 2h (5) + 3h (6)

As you can see you will have a workforce that dinamically take in account a queue item and tries to process item as fast as possible.
If you also have more than one process (i hope for you so) on your BP server, you can also think about a main process that plays with all registered processes in order to use robot workforce in the best way.

Friday, April 14, 2017

A Blue Prism project with custom DLLs

Lately i worked a lot on Blue Prism, which is a RPA software which helps you deal with process automation.
One of the most interesting things about Blue Prism, is that you can use a lot of custom code in order to power up your solution.
For example i designed one of the solution our customers appreciated a lot simply mixing up some old school programming with brand new Blue Prism knowledge.

Let me show you context and architecture before dealing with tips and tricks.
Basically, we need to get some data from the legacy mainframe systems of the customer and we use BluePrism to deal with that using some scripting techniques.
Those data will be used to produce some documents that will be produced starting from some templates which contain some logic.
For example, in the document templates, we have some placeholder like

{FOREACH:PEOPLE}
- Name is {NAME} and surname is {SURNAME}
{/FOREACH:PEOPLE}

that will be translated in
Name is Luke and surname is Skywalker
Name is Anakin and surname is Skywalker
Name is Leila and surname is Organa

where PEOPLE is a Blue Prism collection, or other placeholders that enable a paragraph to be shown or not in some particular circumstances.
This kind of work is done using OpenXML together with Blue Prism using a basic three-tier architecture, if you're curious about, please have a look at this image below.
Why a three tier? Because we share the business logic layer between the application and the robot.
Like you can see in the image, we have an application which deals with a custom DB and is capable of getting data from Blue Prism elaboration in order to create a attended process.

What seems to be not so funny is the fact that BP 5.0.23 is that, even if you reference some DLL (and the code seems to compile) when you run the process, Blue Prism will not work correctly, so you'll need to put all the DLLs into the Blue Prism automate folder, this means you also have to put in that folder also the .config file which contains connection strings or other stuff. This package will be deployed to every robot that will work the process, or maybe could be a the robot itself to download needed DLLs using a configuration process.

What about data transfer between Blue Prism and C#/VB.Net code?
You always have to think about BP Data structure, so, if you have to read a object collection, you have to translate it into a DataTable, in order to read it from Blue Prism, so here's a bit of code to accomplish the task

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?