web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / create a trigger based...
Power Automate
Unanswered

create a trigger based on a specific data in the name of the file

(0) ShareShare
ReportReport
Posted on by 3

Hi, I am just starting with Power Automate and created my first flow. I was wondering if it is possible to assign different recipients for the approvals based on the name of the file?

For example:

File ABCD - would need to go to approver DCBA

FILE XYZ - to go to approver ZYW.

The flow is the same, the trigger - when a file is created in a certain location

Capture.JPG
Categories:
I have the same question (0)
  • rzaneti Profile Picture
    4,483 Super User 2026 Season 1 on at

    Hi @npopova ,

     

    Welcome to Power Automate! 🙂

     

    It is possible to extract date from file name, and find a user email based on that to be used in an approval request. It is similar to what you already have in your flow, but it will require a little more complexity.

     

    Before we start, I'm sharing some blog posts that I wrote about the topics discussed in this answer. You can refer to them for further reference:

    - Working with variables in Power Automate: http://digitalmill.net/2023/07/03/working-with-variables-in-power-automate/ 

    - Writing expressions in Power Automate: http://digitalmill.net/2024/02/27/writing-expressions-in-power-automate/ 

    - For the '[0]' reference - Using loops and accessing array elements in Power Automate: http://digitalmill.net/2023/07/12/using-loops-and-accessing-array-elements-in-power-automate/ 

    - Data Types in Power Automate: http://digitalmill.net/2023/08/03/data-types-in-power-automate/ 

    - How to extract and clean texts with Power Automate: http://digitalmill.net/2023/08/12/how-to-extract-and-clean-texts-with-power-automate/ 

     

    First, right after your trigger, you need to isolate the "XYZ" from "FILE XYZ". You can achieve it by combining some text expressions. Let's add a string variable for that, and after naming it and change its type to "String", click in "Value" input and then in the "Fx" button (highlighted in yellow below):

    rzaneti_0-1716485867849.png

     

    By doing that, you will be able to access the expression pane, where you can manipulate data in Power Automate in an approach very similar to an Excel formula:

    rzaneti_1-1716485918538.png

     

    Now write replace():

    rzaneti_3-1716486398315.png

     

     

    Position your mouse cursor between the parenthesis and then click in "Dynamic content" tab (highlighted in green), search for "name" (highlighted in blue) and then select the property "Name" from the list (highlighted in yellow). By just clicking in "Name", an expression will be added to the pane's input (underlined in red):

    rzaneti_4-1716486436832.png

     

    Still inside the parenthesis, but after the expression automatically added by Power Automate, add the following text: , 'FILE', ''

    rzaneti_5-1716486534838.png

     

    You just created a replace() expression, which is taking the 'FILE' text from your file name and replacing it for an empty string (''). Now surround this whole expression inside the parenthesis of a trim() expression:

    rzaneti_6-1716486608294.png

     

    The trim() is used to eliminate any extra blanks in the beginning or in the end of the string. Your expression is done, so you can just click in "Add", and your variable value will look like this:

    rzaneti_7-1716486670188.png

     

    Now you can add a "Search for a user" action, and pass the variable reference as "Search term":

    rzaneti_8-1716486705840.png

     

    This will search for the user profile in your tenant based on the name extracted from the file name. 

     

    Now you can add another string variable to store the user email. Repeat the process to add an expression, but at this time you will first add a reference to the dynamic content of the "body/value" property from the "Search for users" action (highlighted in yellow):

    rzaneti_9-1716486819761.png

     

     

    After Power Automate adds the expression, include the following text to its end: [0]['Mail'] (highlighted in yellow):

    rzaneti_10-1716486938086.png

     

    By using this expression, we are:

    1. Accessing a list (array) of the users from your tenant which names match with the value extracted from the file name (outputs('Search_for_users_(V2)')?['body/value'])
    2. Selecting the first user returned in this list ([0])
    3. Accessing the email property from this first user (['Mail'])

     

    After saving the flow, I created this file for testing:

    rzaneti_11-1716487111591.png

     

    The flow ran successfully, extracting the user name from the file name (in yellow) and capturing it's email after the "Search for user" action (in green):

    rzaneti_12-1716487173885.png

     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/ 
    https://www.linkedin.com/in/raphael-haus-zaneti/ 

     

  • npopova Profile Picture
    3 on at

    Hi, Thank you.

    I followed the steps, but i get an error message. It is in the second string variable - did i place it correctly?

    npopova_0-1719309564838.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard