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

Sequential conditions and actions on a new file in SharePoint

I am trying to build my first workflow in Power Automate, based off a flow from SP Designer 2013. 

Here's what needs to happen:

When a new file is added, I want to have a Client name field be filled with the name of a client (based off the Client ID), if the client name appears in the file name. 

That seems fairly simple, using a condition I can check if a file name contains a value, then update the file properties, and choose the desired field value.

 

But I have a list of 20 or so clients which can appear in the file name (one client per file name), and have the value of the Client name field be set according to what's in the file name field. So I want the workflow to check the file name against all the possible Client names, and then apply the correct one.

 

How can I go about getting this action completed? In SharePoint Designer I have a list of conditions with updates, linked by a series of OR statements. But what's the best (or simplest!) way to achieve this in Power Automate?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint

@ChristianAbata Thanks again for your help (and patience!)

 

The workflow is built like 

2020-03-04 13_58_08-Window.png

 

2020-03-04 13_58_23-Window.png

 

2020-03-04 13_59_42-Window.png

 

2020-03-04 14_09_48-Window.png

 I looked at this article for the compose and update file properties: https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Update-a-secondary-SharePoint-list...

 

When I run the flow the first two steps of the flow show green. I can see the correct metadata in the log of the flow, both for the file and for the Get function on our list of clients.

The error I see is in the compare condition. I've tried reversing the fields, or using just the "name" of the document instead of the name with the file extension. Nothing changes the result (below): 

2020-03-04 13_58_48-Window.png

 

2020-03-04 13_59_22-Window.png

So it runs but returns a negative result, while the necessary client name exists in the client list and in the name of the file. In the file name, the client name is typed as a separate word: Weekrapportage [client name] - 2019-12-06 - DG 103,2.pdf. The SP Designer workflow that I made in the 2013 environment worked fine on this file.

 

 

 

 

 

View solution in original post

14 REPLIES 14
Highlighted
Super User III
Super User III

Re: Sequential conditions and actions on a new file in SharePoint

hi @RussH  whe you work in PA, you can see the outputs of the actions, for example you could use get files (Propertis Only) and that acction gives you an output for example

{

Onwer: 'Hola mundo'

Permisions: 'Write'

}

{

FileName: 'Client1, client2, client3..etc'

}

Please as you see the second output is an array, an you can manage this array by using Parse Json, then you are going to be able to worok with the object and apply every condition you want. 

 

Please see this example of how to use parse Json.

json.PNG



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint

@ChristianAbata: Even though I've made basic workflows in SP2013, I basically know nothing of json or programming in json. I had started experimenting with this: 

2020-02-25 16_49_44-Edit your flow _ Power Automate.png

But this kind of construct, only repeated for each possible variation on the condition, won't work? As I am not a programmer, I am looking for something that a business user can build (if possible). 

 
Highlighted
Super User III
Super User III

Re: Sequential conditions and actions on a new file in SharePoint

mmm @RussH  if you want to do a basic flow as you show in the screnshot, it works perfectly to common users, so it's ok. But If you want something more complex insted of repeating the same flow you can use just one using fuctions or do until loop. 

I can help you do builst whateveer you want if you discribe me what you want. 😉



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint

@ChristianAbata : first, thanks for your response and your willingness to help constructing this! If we are to work on this, do we keep doing that here, on this platform (seems the best as then it's an example others can benefit from)? Let me know, then I'll detail what it is I am looking for (context, actions, fields used, result).

Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint

@ChristianAbata , I was away for the weekend, and thus am picking this back up now.

What I am wanting to do is:

 

Make a workflow that understandable is for the site manager (who like me does not know much about code) which does the following:

When a file is uploaded to the target library, the flow checks which client name the filename contains (example: Weeklyreport [clientname] week 16.xlsx\), and fills the field "Client" with the appropriate abbreviation of the client name. This allows users to filter on the client abbreviation within the library.

The field "Client" is a lookup field refers to a separate sharepoint list on the site of client names and their abbreviations, and shows the abbreviation.

 

In SharePoint Designer I had simply used a repeating either/or construction: if the current item name contains client name A, then add abbreviation A to client field in current item. Otherwise, if the current item contains client name B, then add abbreviation B... and so on. If nothing was found, the workflow2 simply stops and logs that no valid client name was located.

 

The workflow only needs to run when a file is uploaded to the library, not when it's contents is changed. 

 

Each possible option was listed as a separate either/or item, and of course needed to be updated if new clients were added (at present the number of clients is 12, so not at all complex). But I suspect this is not the most efficient way to realize this, and I am very willing to learn new/better ways of achieving the desired result.

 

Does this describe the desired actions clearly enough for you?

Highlighted
Super User III
Super User III

Re: Sequential conditions and actions on a new file in SharePoint

hi @RussH  I think this is what you need.

First I create a sharepoint list with my clients then in the flow I get that list to compare it when a file is uploaded to a folder or created into a folder like this.

list1.PNGwhen.PNGlist3.PNG



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint

@ChristianAbata Christian, is the folder value necessary? We've been using document sets as an organizing principle, with a separate document set per week. So in the construction I've used so far, the "location" is flexible (varies from week to week). 

Sorry that I neglected to mention that.

Highlighted
Super User III
Super User III

Re: Sequential conditions and actions on a new file in SharePoint

no @RussH  you can leave the field blank if you want all directory

when a file.PNG



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint

@ChristianAbata , thanks for you help so far. I have a couple of questions, if you don't mind.

 

1) in the GET of the list, I don't need to specify a query in the "Filter by" or "order by" fields? Don't I here need to determine what the "value" of the next step is?

2) Your example of the condition shows "Titulo" (title of the item in the list of clients) contains "Nombre" (name of the file). Isn't that backwards? Rather that the name should contain the title of the client?

3) What is "exist" in "Compose". Should this not be the field to which I want to place the abbreviation? in that case I need (I think) to say that "If the title from the client list is found in the name of the file, then place the abbreviation of the title (a second field in my client list) in the client field in the document library? 

Highlighted
Super User III
Super User III

Re: Sequential conditions and actions on a new file in SharePoint

hi @RussH  filter Query is just to specify if you wnat some data from all of your sharepoint list.

In my Example Title is the name of the column you can change it if you want.

Exist in compose is just you let you know that a value compared in the condition is true or is founded in the list.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint

@ChristianAbata I think I still need to work on this, for I keep getting an error at the condition as listed. I've tried various combinations, but so far nothing seems to return a positive value. Testing the flow returns a "false" value for a document that contains a name from the client list. 

Highlighted
Super User III
Super User III

Re: Sequential conditions and actions on a new file in SharePoint

Please @RussH  share us an screanshot and then sure I can help more



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint

@ChristianAbata Thanks again for your help (and patience!)

 

The workflow is built like 

2020-03-04 13_58_08-Window.png

 

2020-03-04 13_58_23-Window.png

 

2020-03-04 13_59_42-Window.png

 

2020-03-04 14_09_48-Window.png

 I looked at this article for the compose and update file properties: https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Update-a-secondary-SharePoint-list...

 

When I run the flow the first two steps of the flow show green. I can see the correct metadata in the log of the flow, both for the file and for the Get function on our list of clients.

The error I see is in the compare condition. I've tried reversing the fields, or using just the "name" of the document instead of the name with the file extension. Nothing changes the result (below): 

2020-03-04 13_58_48-Window.png

 

2020-03-04 13_59_22-Window.png

So it runs but returns a negative result, while the necessary client name exists in the client list and in the name of the file. In the file name, the client name is typed as a separate word: Weekrapportage [client name] - 2019-12-06 - DG 103,2.pdf. The SP Designer workflow that I made in the 2013 environment worked fine on this file.

 

 

 

 

 

View solution in original post

Highlighted
Frequent Visitor

Re: Sequential conditions and actions on a new file in SharePoint - Solved!

@ChristianAbata So I've managed to get this workflow working, using your advice (many thanks)! Here's what I have:

 

2020-03-11 14_37_48-Edit your flow _ Power Automate and 2 more pages - Work - Microsoft​ Edge.png2020-03-11 14_38_28-Edit your flow _ Power Automate and 2 more pages - Work - Microsoft​ Edge.png

 

I had first labelled the condition to look for the abbreviated form of the client in the filename, which was simply the wrong choice. Of course, this needed be the field that contained the full client name. Beginner's error.

 

The second was to join the ID from the "Get" to my field "Klant Id -1", which is the list ID number from the "Get items" (client list). And of course to ensure that the mandatory of ID for the file itself was filled with the ID from  the "When a file is created" values.

Thanks again for your assistance!

 

Russ Herald

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,012)