cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
STURNER
Frequent Visitor

Flow to assign documents to different people

Hi, I want to automatically complete the 'Assigned To' field when a document of a certain name is added to a sharepoint library and then notify that person.

Can anyone help please? 

1 ACCEPTED SOLUTION

Accepted Solutions

@STURNER Thanks for your patience on this!

Reporting here how we solved this flow.


In the condition, the "Name" item on the right frame was pointing to another column in the SPO library (probably also named "Name"). Changing it to the default library "Name" item made the condition work.

We also changed the trigger to "When a file is created" to avoid infinite loop.

View solution in original post

17 REPLIES 17
fchopo
Super User
Super User

Hello @STURNER 

In order to help you, you should provide more detailed information:

1) Which is the condition to be accomplished to trigger the flow? By file name?

2) Which task must be changed? Or the task should be created? (it doesn't exist).

3) Is the user who is uploading the file to SharePoint the one that has to be assigned to the task?

Regards,

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
STURNER
Frequent Visitor

Thank you - answers below: 

1) Which is the condition to be accomplished to trigger the flow? By file name? 
Yes the file name would be the trigger as the file is being created through a document set so filename will always be the same

2) Which task must be changed? Or the task should be created? (it doesn't exist).
A new task would need to be created or just a notification sent to that user (chat in teams or email with link)

3) Is the user who is uploading the file to SharePoint the one that has to be assigned to the task?

No - a central administrator will create the document set which creates 10+ documents.  I then want a flow to assign the documents to relevant people (as unfortunately doc sets can't do that).  

Thanks

@STURNER Let's proceed step by step.

First of all, you can have your trigger use the file name as a condition by setting it like below:

 

1. For the trigger, choose a "When a file is created (properties only)" from SharePoint connector.

2. Set the site address and library name.

3. Open the trigger settings from [...] and add the "Trigger Condition" below:

       @equals(triggerBody()?['{Name}'], 'certainName') 

 

Replace "certainName" by the file name you want the flow to trigger at.

 

Please let me know if that helps and we'll move on to the next step. Thanks.

@JulienOlivier Hi, I have done that, can you help me now update the assigned to field with a specific person / group depending on document name and then send an email to them?  
Thanks so much in advance

STURNER
Frequent Visitor

Flow trigger.png

I have found that I can assign to a sharepoint group but not to an individual?  What syntax do I need to do that?

Thanks

@STURNER Here SharePoint groups are available in the dropdown selection, but you can also directly type individual (people in your tenant) account Email address. Or you can also enter it as dynamic content (click on "Enter custom value" for that).

 

Also, with the setting we made in the trigger, the flow will trigger only for one specific document name. So we cannot update the "Assign To" field depending on the document as it won't vary.

Else, we could remove that trigger setting to let the flow trigger each time a file is created. And then use a "Switch" that will update the "Assign To" field with a account Email address that depends on the document name.

 

Is it what you initially wanted to do?

@JulienOlivier  yes there are about 10 documents created as part of a document set and each one needs to be assigned to someone different so your suggestion of a switch sounds better but I don't know how to do that.  Can you help please?

@STURNER Ok, yes we can use a switch for that.

We can also create a dictionary that will store which file name belongs to which "Assigned To" account. That way it will be less cumbersome to do, I think. Let me explain how to do that below:

 

1. Add a "Compose" action and create a dictionary like below. I entered 2 sets but feel free to enter all your 10 sets.

(make sure to respect the syntax)

 

[
{
"fileName": "name1",
"assignedTo": "john@company.com"
},
{
"fileName": "name2",
"assignedTo": "bob@company.com"
}
]

JulienOlivier_0-1593638317386.png

 

2. Add a "Parse JSON" action.

In "Content", select the compose "Outputs" from dynamic content.

In "Schema", click on "Generate from sample", paste your whole dictionary and click "Done".

JulienOlivier_1-1593638570727.png

 

3. Add a "Condition".

At "Choose a value" on the left, pick "Parse JSON > fileName" in dynamic content (this will create an "Apply to each" frame).

Open the "Condition" action again.

At "Choose a value" on the right, pick "When a file is created (properties only) > Name" in dynamic content.

Then in the "If yes" frame, add an "SharePoint > Update file properties" action.

In the "Assigned To Claims", pick "Parse JSON > AssignedTo" from dynamic content. 

photo1.png

 

4. In the trigger settings, don't forget to remove the condition we created before.

 

That should be it. Give it a try and let me know if it worked as you expected!

 Hi, it runs ok i.e says the flow succeeded but it doesn't update the assigned to column and when I go into look at the run I get this;

 

STURNER_0-1593785466546.png

 

Hi @STURNER Thank you for trying.

The message that you got when you look at the run, is what should happen when you add a file in the library for which the file name is not in your dictionary. Could you double-check on that?

 

If you have a doubt, please post your dictionary and the file name here and I will take a look. Thanks.  

Here is my compose step;

[
{
"fileName": "1 Trustees Agenda",
"assignedTo": "taccount@blenheimpalace.com"
},
{
"fileName": "12 Date of next meeting",
"assignedTo": "taccount@blenheimpalace.com"
},
{
"fileName": "2 Draft minutes",
"assignedTo": "taccount@blenheimpalace.com"
},
{
"fileName": "3 Matters Arising",
"assignedTo": "taccount@blenheimpalace.com"
},
{
"fileName": "4 CEO Report",
"assignedTo": "taccount@blenheimpalace.com"
},
{
"fileName": "6 Strategic Land Update",
"assignedTo": "taccount@blenheimpalace.com"
}
]

 

Then in Parse JSON I hit Generate from sample and pasted the above into it - if you select Peek Code it looks like this;

 

{
    "inputs": {
        "content""@outputs('Compose')",
        "schema": {
            "type""array",
            "items": {
                "type""object",
                "properties": {
                    "fileName": {
                        "type""string"
                    },
                    "assignedTo": {
                        "type""string"
                    }
                },
                "required": [
                    "fileName",
                    "assignedTo"
                ]
            }
        }
    }
}
 
In the run history, it runs 7 times - once for the doc set folder and once for each of the 6 documents.
but using one of the runs which relates to a specific document you can see the output relates to one of the doc names in my dictionary
 
 

Annotation 2020-07-08 094011.png

 

 

 

 

@STURNER I don't see any problem in your Compose and Parse JSON steps. There are identical to mine.

In your run history, at Condition inside the "Apply to each", when upload your doc file to your library, you should have 5 "false" and 1 "true". Could you check on that?

 

Also, here is a screenshot of my flow that is working. Please compare it with yours.

I have set my Compose and Parse JSON steps identical to yours.

flow1.png

Hi

Thanks so much by the way for trying to help!  It is very much appreciated

In my run data, all 6 state False.  

STURNER_0-1594312394445.png

 

The only difference in my flow is that my initial trigger is When a File is created or modified (properties only) - could that be the issue?

Hi @STURNER 

Well, thanks for your patience too 🙂

 

No, the trigger that you use is not the cause.

There must be a problem in your condition. For some reasons, it's not satisfied.

Could you check its definition again?

 

It should be something like below.

JulienOlivier_0-1594332219351.png

If you happen to change an action or trigger that the condition is referring to, it may alter its definition.

 

Also, if you still meet this problem, could you paste a screenshot of the entire definition of your flow (with trigger and actions open)? I will take a look. Thank you.

 

step2.pngstep1.png

STURNER
Frequent Visitor

Hi @JulienOlivier sorry images posted the wrong way round but you will get the idea.  Does this help.  All looks OK to me?

@STURNER Thanks for your patience on this!

Reporting here how we solved this flow.


In the condition, the "Name" item on the right frame was pointing to another column in the SPO library (probably also named "Name"). Changing it to the default library "Name" item made the condition work.

We also changed the trigger to "When a file is created" to avoid infinite loop.

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,568)