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 / (Desktop) File not fou...
Power Automate
Answered

(Desktop) File not found with dynamic path

(0) ShareShare
ReportReport
Posted on by 11

Hi, everyone.

 

I'm using Power Automate to automatize emails according to the data in an Excel worksheet. For my job, I keep track of every invoice I register in our CRM in an Excel file. When an invoice is recorded, I change the value in the "Status" column to "Registered" and email the Accounting department with the PO and invoice.

 

I keep the files in this path:

 

G:\My Drive\01 Entries\Active\SupplierName PO 1234

 

My company requires us to use Google Drive, so I can't use OneDrive. 

 

The files I want to attach have the following name format:

 

01 YYYY-MM-DD PO 1234 SupplierName.pdf

 

 

The variables for the file names and the data for the email's body are retrieved from the Excel file. 

 

I'm getting the data from Excel with an SQL connection, as described on this page: https://learn.microsoft.com/en-us/power-automate/desktop-flows/how-to/sql-queries-excel

These are the steps in my flow (summary):

  1. Define the variable with Excel's path.
  2. Open the SQL connection.
  3. Query the data that I need to populate the email and define the file's paths.

Nevertheless, when it comes to the step of sending the email, I got the error that the file doesn't exist.

I know the error is in the variable. If I write the path without using the variables it works, but when I use the variables, it doesn't find the file.

 

The variables I need to get the paths are these:

For the folder's path:

  • Supplier's name
  • PO#

For the files:

  • Document kind ID (01 for PO, 02 for Invoice, 03 for entry acknowledgment)
  • Document's date (in YYYY-MM-DD format)
  • Document kind ("PO" for PO, "INV" for Invoice, "Entry" for entry acknowledgment)
  • Document ID (integer for PO, string for Invoice. Entry acknowledgment doesn't use)
  • "PO" + PO# (for Invoice and Entry Acknowledgment).

*For the date, to avoid getting it as an integer, I convert it to string in Excel with this formula:

 

IF(AND(LEN(MONTH($M2))=1;LEN(DAY($M2))=1);CONCATENATE(YEAR($M2);"-0";MONTH($M2);"-0";DAY($M2));IF(LEN(MONTH($M2))=1;CONCATENATE(YEAR($M2);"-0";MONTH($M2);"-";DAY($M2));IF(LEN(DAY($M2))=1;CONCATENATE(YEAR($M2);"-";MONTH($M2);"-0";DAY($M2));CONCATENATE(YEAR($M2);"-";MONTH($M2);"-";DAY($M2)))))

 

 

I tried this without result:

  1. Using directly the SQL query results to determine the file's path. Concatenating the variables as follows: 

 

G:\My Drive\01 Entry\Active\%supplierNameQuery% PO %ocIdQuery%\01 %poDateQuery% PO %poIdQuery% %supplierNameQuery%.pdf​

 

  • Concatenating the file's path in Excel and adding %poFilePathQuery% in the outlook action.
  • I tried to store %poFilePathQuery% in a new variable (%poPath%), but it didn't work too.
  • I discovered that there was an extra line in the query, so I used the trimming action, but %TrimmedText% didn't work too.
  • Tried to reconvert %TrimmedText% with two Python scripts, but didn't work:

 

#Try 1 (didn't work)
path = %TrimmedText%
print(path)
#It output anything

#Try 2 (didn't work)
path = str(%TrimmedText%)
print(path)​
#It output anything

 

I discovered that the path variable only works until the directory's path (G:\My Drive\01 Entry\SupplierName PO 1234), but it doesn't with the file's name if it's and string, but as an integer, it works.

For example

 

Works: G:\My Drive\01 Entry\Active\SupplierName PO 1234\1.pdf

Doesn't work: G:\My Drive\01 Entry\Active\SupplierName PO 1234\01 2023-01-01 OC 1234 SupplierName.pdf

I have the same question (0)
  • rubusarbaro Profile Picture
    11 on at

    Ps: In some code examples I use "01 Entries" and in others "01 Entry". Or "OC" instead of "PO". This is because I'm translating the paths from Spanish to English, and I didn't pay attention to what words I used before.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Have you tried running your flow in debugger to see the values in your variables? It might be that not all of them, but only one or a few of them are incorrect.

     

    While you did provide a very detailed explanation, it still is quite difficult to pinpoint the exact problem without seeing your flow or knowing which variable(s) does not work.

     

    Can you maybe share a screenshot of your flow that does all this? Also a screenshot of what the output of the SQL query looks like (cleaned up of any sensitive data, of course)?

    -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

     

  • Verified answer
    rubusarbaro Profile Picture
    11 on at

    Man, I feel so dumb.

    The problem was that the file in my folder wasn't following the standardization I did.

     

    File name in folder (outdated): 01 2023-01-01 SupplierName OC 1234.pdf

    Expected file name (updated): 01 2023-01-01 SupplierName PO 1234.pdf

     

    Two letters made me desperate. Before August I was using "OC" to name the file, but my boss asked me to change it to "PO". I was using a file with the previous naming system.That's why it wasn't working.

     

    I'm sorry to made you read my post, but also I thank you so much for take your time to help me.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 246 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 176

#3
Haque Profile Picture

Haque 157

Last 30 days Overall leaderboard