Grant access to folder in SharePoint for Access Team members with Flow

Posted by

There was a question on the Dynamics CRM community forum how to add folders to a document location in SharePoint and grant access to that folder for the members of the Access Team on a record in Dynamics 365 CE. This turned out to be much easier than I first thought, especially with the new actions of the SharePoint connector in Flow.

Here is the overview of the Flow:

To start the Flow I will use the trigger When a (Opportunity) record is selected. Then I list the related Document Location record to get the value of the Relative URL field, that is set in the compose action: first(body(‘List_Document_Location_record’)?[‘value’])?[‘relativeurl’]
Next action is to create the folder in the target library with the path: relativerurl/shared

Next part of the Flow is to get the Access Team regarding the selected Opportunity. The teamid is set in the compose field: first(body(‘List_Team_record’)?[‘value’])?[‘teamid’] and used to list the members of this Access Team. Enter the Entity Name as a custom value: teammemberships

For each Team member I get the User record: items(‘Apply_to_each’)?[‘systemuserid’] and use the Primary Email address to grant access to the folder id that was created.

Now when I run the Flow from the Opportunity, as a result a folder is created and shared with the two specific users of the Access Team.

In this way a more sophisticated integration of Dynamics 365 CE and SharePoint becomes easier to realize.


  1. Hi Stefan,

    Great article, I’ve tried to follow the steps but for some reason I get an error in the “List Team Membership records” step using the filter query whenever running the flow.

    From the error(see below) I assume it’s due to comparing different datatypes. Would you have any idea how to workaround, I guess you didn’t encounter this issue?

    “A binary operator with incompatible types was detected. Found operand types ‘Edm.Guid’ and ‘Edm.String’ for operator kind ‘Equal’.”

    1. Hi Hans,
      Do you use the Common Data Service or Common Data Service (current environment) connector for this action?

  2. Hi Stefan,
    I’ve used the CDS with current as environment, thus should be exactly like you have used it. But for some reason it keeps throwing the same error when running the flow.

    Any ideas would be greatly appreciated..

Leave a Reply

Your email address will not be published. Required fields are marked *