I’ve been working on a problem that’s been plaguing me for months and now, thanks to Microsoft Business Solutions MVP Aiden Kaskela and his Workflow Elements solution, I’ve finally managed to get it sorted.

The Problem

I wanted to be able to conditionally add members of one Team to another with a workflow, without hard coding the specific Users into the workflow.

My specific scenario was as follows:

If an Opportunity meets certain criteria, an Owner Team is automatically created and linked to the record.  The new Owner Team should then be updated to include Users who are in another Owner Team (the Proposals Team in my scenario).

Dynamically Add Users to Opportunity Team

Why couldn’t we just link the Proposals Team to the Opportunity I hear you ask?  Good question, it is because the Proposals Team are the minimum members of the New Opportunity Team and each Opportunity Team may have multiple other Users added to it from across the business.

We use the Teams as part of our custom integration with SharePoint; adding a User to the Team automatically assigns them specific permissions in SharePoint so we needed specific Teams per Opportunity.

I went round in circles for a long time trying to work out the most efficient solution for this, but I kept running into issues.  I was able to achieve steps 1-4 from the image above, but could never quite complete the process.  The closest I came was using the “Add User to Record Team” N:N associate step from Andrii Butenko’s Ultimate Workflow Toolkit, however this still required me to add a step per user and hard-code their name into the Workflow, which meant I would also then have to deactivate the workflow and update it if the composition of the Proposals Team changed.

I asked in the CRM Community Forum to see if anyone else could help but still ran into the same issues.  I reached out to Aiden Kaskela about a month ago to see if he could help and today he’s delivered in spectacular style

The Solution

Aiden has updated his Workflow Elements solution to include a new step – “Relationship – Associate From Query” (available from V2.1.0) which makes my scenario really simple to solve

Kaskela Workflow Solutions

Getting this step to work couldn’t be easier.  You add it to your workflow, then select the N:N Relationship Name, and then you have the option of using a System View, Personal View or FetchXML query to select the records to be associated.  For my scenario, this was triggered on the Team entity, and used a Personal View on the System User entity to find the members of the Proposals Team

Relationship - Associate from Query

I love the simplicity of this workflow step, and I can envisage a number of additional scenarios that this could be used for in my environment.  It makes it really easy to develop complex, dynamic association workflows.

Conclusion

Solving this problem has demonstrated two things to me:

  1. Dynamics CRM/365 is an amazing platform, and the flexibility it offers developers and customisers to deliver on much-needed functionality is so useful.  The system gets better with every release, and it makes it a pleasure to work with
  2. More importantly, the CRM/365 Community is incredible.  There are so many developers who create tools and plugins that they make available for free for us all to use, and they make my job so much easier.  Their creativity and generosity astounds me, and I am so grateful to them for everything they provide.

I could not recommend the Kaskela Workflow Elements solution enough.  I use it for so many applications, and this latest release makes it even better.  Please go and visit his website, download the solution and try it out; I guarantee you’ll love it.