The problem

A client recently reported that they were experiencing random issues with the process that is responsible for automatically creating a Document Location and SharePoint folder when an account record is created in their Dynamics365 environment. Sometimes it works… sometimes it doesn’t.
As a technical consultant, that’s not something you like to hear. I would rather have it failing all the time then 🙂
In the system jobs I found out that the error messages varied between timeouts, unauthorized access, too many SharePoint requests, …

Now, this process was implemented using a custom workflow assembly.
Nothing out of the ordinary here, I’ve seen this before.
And as usual, I started shivering when seeing the SharePoint related code.
It always seems quite the hassle to perform a small task like creating a folder.
Surely this can be done a whole easier these days?!?

The solution

After Googling around a little, it seemed to me that most people try to implement this logic using Power Automate these days.
So, instead of trying to understand and refactor all the current code, let’s try that!

I’m not going to discuss the detail of the flow, there are plenty of examples out there.
But here is how it, in its simplest version, looks like.

The results

When creating an account through the user interface of the Dynamics365 system, everything works as expected.
But this hardly counts as a real test.
Time to find out what this thing can actually do!

I ran a console application, which created hundreds of account records using the ExecuteMultipleRequest class. Simulating some kind of integration scenario.
And the results are simply amazing!
Not a single error!
Maximum execution time was 2 seconds!!
Most of the runs finished in milliseconds!!!

The benefits

First of all the success rate of this process is currently 100%. Which makes it much more reliable then the previous implementation.
It’s also faster as the old workflow.
The Power Automate flow looks a lot cleaner than the C# code written in the custom workflow assembly.
Everyone can understand what this process will do when seeing this.
Not to mention that this took me only a few minutes to implement.