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 / Power Automate Flow Su...
Power Automate
Suggested Answer

Power Automate Flow Suddenly Failing with "Invalid File Name" for Dynamic OneDrive Filenames

(1) ShareShare
ReportReport
Posted on by 2
I've had a Power Automate flow running successfully for about two months with over 150 submissions. It uses a dynamic filename (JP-yyyyMMdd-HHmmss) to create Word and PDF files in OneDrive. On 19 Jun 2026, it suddenly started failing with "Invalid file name" in the Create File action, even though nothing was changed in the flow, template, folder, or licensing. The JP number is generated correctly, the Word template is populated successfully, and storage is not an issue. Interestingly, a static filename like test.docx works, but the dynamic filename no longer does. I'll attach screenshots of the last successful run and the first failed run on the same day for comparison. Has anyone encountered something similar?
Screenshot 2026-06-20 083025.png
Screenshot 2026-06-20 083048.png
Screenshot 2026-06-20 082931.png
Categories:
I have the same question (0)
  • Suggested answer
    Haque Profile Picture
    3,557 on at
    Hi @AA-20060055-0,
     
    Thanks for posting the issue here. One good thing is it works with static filename like test.docx. In the fiest place I suspecte while creating the file name dynamically something coming bad that preventing standard file name, length etc.
     
    Let's list out the possible reasons:
     
     
    1. Invalid characters or formatting in the dynamic filename: hidden or unsupported characters like line breaks, special Unicode characters, or trailing spaces that cause the error.
    2. Filename length or path length limits: SP and OneDrive have limits on filename length and total path length (usually 400 characters max) - need to make sure if we are exceeding.
    3. Starting filename with a number or reserved words: Some systems disallow filenames starting with certain characters or reserved words. Adding a prefix letter can help.
    4. Changes in Power Automate or connector validation: Sometimes MS updates the backend validation rules for filenames, making previously accepted dynamic names invalid if they contain subtle issues.
     
    What we can do:
     
    1. Santize the filename that dynamically creating: Let's replace slash, break, newline, underscore, empty space and underscore.
    replace(replace(replace(variables('YourFileName'), '\n', ''), '\r', ''), ' ', '_')
    
     
    2. Trim the file name, let's remove leading/trailing spaces with trim().
     
    3. Preventinve measure is alwasy best - let's add a safer prefix like "JP_"
     
    4. We can try a GUID based file name like:  concat('JP_', guid(), '.docx')
     
    5. Finally, test the file name output to check,  let's use a Compose action before Create File to output the filename string and verify it visually.
     
     
    References:
    1. How do I remove or replace every special character
    2. Avoiding naming issues
    3. Create file action
    4. File Path limits in SP and OD
     
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
     
  • Suggested answer
    11manish Profile Picture
    3,114 on at
    Given that:
    • Static filenames work.
    • The failure started suddenly.
    • The template generation still succeeds.
    The most likely cause is that the dynamic filename now contains an invalid character, unexpected whitespace, or a formatting change in one of the values being concatenated into the filename. Checking the resolved filename value in the Create File action inputs should be the first step.
  • Suggested answer
    BCBuizer Profile Picture
    22,827 Super User 2026 Season 1 on at
     
    The first thing I would do is to remove the line break (/n) before the .docx part. I see it is included also in the last successful flow run, but it just does not seem right;
     
     
     
    If this reply helped you in any way, please give it a Like 💜 and in case it resolved your issue, please mark it as the Verified Answer ✅.
     
     
     
     
    Thanks for posting, we appreciate your desire to help the Community!
     
    I think your reply might be an AI-assisted post, but I do not see any tools or sources cited. Can you update the post to include your sources, or confirm this was not produced using AI?
     
    Please refer to the Use AI responsibly section of Writing effective responses in the community:
     
    Do not
    • Copy and paste AI-generated answers into the forum without verification. While AI is a valuable tool, it is not always correct, and can provide detailed answers that look correct, but are not.
    • Conceal the use of AI. If your answer was written in concert with AI, be forthright about it to ensure that others have an opportunity to review or vet your response for accuracy.
     
    Thank you!
     
  • Haque Profile Picture
    3,557 on at
    Hi @BCBuizer,
     
    Thanks for the guidance, I have updated my post with supportings.
     
  • AA-20060055-0 Profile Picture
    2 on at
    Thank you  for your suggestions. I tested several scenarios and found out that Static filenames such as test.docx, test1.docx, and even JP-20260623.docx work successfully, and the flow completes without issues. However, whenever I use the filename generated from the Compose output (whether using the original format, a full expression, or even a GUID), the OneDrive Create File action fails with "Invalid file name". The Compose output appears valid, the Word template is generated successfully, and the JP number is correctly displayed in both the document and email. Based on these tests, it seems the issue may not be the filename format itself, but something related to how the dynamic Compose output is being passed to the OneDrive Create File action. Do you have any thoughts on what could cause this behavior?
     

    Dear ,The (/n) characters are being generated automatically by the system. Kindly advise how to remove them. Please see the attached picture for reference. 

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 463

#1
Valantis Profile Picture

Valantis 463

#3
11manish Profile Picture

11manish 264

Last 30 days Overall leaderboard