Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

Failed to Create File

(0) ShareShare
ReportReport
Posted on by 125

Hi Folks!

 

I have a flow that will create a file but the user can upload the same file. I'm having issues since the previous file have already the same filename.

 

Is there a way to create a filename(1).xlsx if the file name already existing? 

 

I want to put that error handler if the create item triggers an error.

  • SudeepGhatakNZ Profile Picture
    SudeepGhatakNZ 14,231 on at
    Re: Failed to Create File

    Can you expand the actions for me, please?

     

  • philifova Profile Picture
    philifova 125 on at
    Re: Failed to Create File

    @SudeepGhatakNZ 

     

    Hello, I followed the method you provided but I'm receiving an error. It says "A file with the name Shared Documents/*****/fileName.pdf already exists. 

     

     

    philifova_0-1671678059836.png

     

  • Re: Failed to Create File

    Hi @philifova ,

    Sorry,
    The above method can only change it to FileNama(1).xlsx, FileNama(2).xlsx when it has the same file name as FileNama.xlsx. . . . . . .

     

    Please try @SudeepGhatakNZ's approach
    His method is better suited to your needs

     

    Best Regards

    Cheng Feng

  • SudeepGhatakNZ Profile Picture
    SudeepGhatakNZ 14,231 on at
    Re: Failed to Create File

    Just as I added two actions, you can instead add two scopes.

    Each scope would have a Create file action followed by a set variable action (where you can save the create ID).

    You could then just reference the variable instead of referencing the ID from the action. Makes sense?

     

  • philifova Profile Picture
    philifova 125 on at
    Re: Failed to Create File

    @SudeepGhatakNZ 

     

    Hello,

     

    The one you provided actually works as well, but the problem is I'm referencing the Id of create file to get the list rows and table. Hence, if there two create file flow how can I reference the right Id?

  • SudeepGhatakNZ Profile Picture
    SudeepGhatakNZ 14,231 on at
    Re: Failed to Create File

    In the example I provided above, I am appending utcnow() to the filename, so it will always be unique.

     

  • philifova Profile Picture
    philifova 125 on at
    Re: Failed to Create File

    @v-chengfen-msft 

     

    I have a follow up question, the flow you provided actually works but if the user upload the same file again for the 3rd time. the file name is same filename(1).xlsx that will trigger an error to my flow. 

     

    It should be filename(2).xlsx, since filename(1).xlsx already exist.

     

     

     

     

  • Re: Failed to Create File

    Hi @philifova ,

     

    Do you want:
    1. Determine whether there is filename.xlsx
    2. If yes, change the name to filename(1).xlsx when [Create file]

    Here is a test for your reference:

     

    Here is library:

    vchengfenmsft_0-1670811582193.png

    Here is flow:

    Not sure what your trigger is, I use a manual trigger to enter the filename and file content

    Use Filter Query to filter out files with the same name in the folder.

    If the Value length is greater than 0, modify the file name when creating the file

    vchengfenmsft_0-1670813095620.png

    vchengfenmsft_4-1670812147088.png

    Here is result:

    vchengfenmsft_1-1670811647788.png

    vchengfenmsft_2-1670811933151.png

     

    Best Regards

    Cheng Feng

  • SudeepGhatakNZ Profile Picture
    SudeepGhatakNZ 14,231 on at
    Re: Failed to Create File

    Will the following work?

    The second Create file action has Configure run after properties been set to execute if the action above fails.

    SudeepGhatakNZ_0-1670810578021.png

    SudeepGhatakNZ_2-1670810642197.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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard