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 / Getting A Filename Fro...
Power Automate
Unanswered

Getting A Filename From SharePoint Document Folder and Creating the File In another Folder using PowerApps V2 trigger

(0) ShareShare
ReportReport
Posted on by 13

I have looked everywhere to try and resolve this but cannot work it out.  I have a Flow set up where it copies an attachment from a SharePoint List to a SharePoint Document Library.  Once it is in a Library, I am trying to make another flow using the PowerApps v2 trigger that reacts when a button is pressed.  The button is linked to a PowerApps Gallery that lists people's names and an .docx attachment.  I would like to move the file of the selected person from one folder in the SharePoint document library to another.  I first tried 'Get Files' and 'Get File Properties' instead of using the PowerApps trigger, but it moves all the files in the folder, not just the one that is linked to that person.  I've since found a different way to do this using the PowerApps trigger, and to a certain extent got it working.  

 

I have used this code in OnSelect in PowerApps:

MovetoRejected.Run(
    {
        File: {
            contentBytes: First(DataCardValue22_1.Attachments).Value,
            name: First(DataCardValue22_1.Attachments).Name
        }
    }
); SubmitForm(FormDecision); Patch('Completion List', LookUp('Completion List', 'Submission ID'=Text(DataCardValue42.Text)), {Status:{Value:"Rejected"}});  Navigate(BrowseScreen1);
 
My question is, how do I get the filename to pull through to the flow from PowerApps?  If input the actual filename myself in the 'File Name' field in the flow it works perfectly.  If I try and call the File Name from PowerApps it fails. 
 
Flow Screenshot 1.png

Flow Screenshot 1.png
Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @Strikerman10 

    According to your screenshot , you put two parameters (File Content and the File Name )in Power apps V2 trigger.

    So you need to pass two parameters in Power App side, like this:

    MovetoRejected.Run(
        {
            File: {
                contentBytes: First(DataCardValue22_1.Attachments).Value,
                name: First(DataCardValue22_1.Attachments).Name
            }
        } , First(DataCardValue22_1.Attachments).Name
    )
     
    And you can also get the file name in the flow side and you just need one parameter in your trgger.
    You can use this expression to get the fileName:
    triggerBody()['file']['name']
    vyueyunmsft_1-1714699333586.png

     

     

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     


     

     

     

  • Strikerman10 Profile Picture
    13 on at

    @v-yueyun-msft thank you for your help.  Unfortunately I could not get this to work.  I think the formula was ok, but the flow kept giving me an error '403 Access Denied' when using 'Create file' action.  I am not sure why this is, as I am the owner of the SharePoint List and Library that I am using.  When I remove the file name being pulled from PowerApps and instead insert a static file name in the flow instead it works.  This is the setup when it is working:

    Strikerman10_0-1715249011214.png

     

    This is the setup that fails with the access denied error when trying to pull the filename from the PowerApp 

     

    Strikerman10_1-1715249096196.png

    Error is:

    Access denied.
    clientRequestId: 75df81de-fda0-4f36-979b-0c847aff927b
    serviceRequestId: 75df81de-fda0-4f36-979b-0c847aff927b

     

    Any ideas on what is happening here?

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi, @Strikerman10 

    Thanks for your response! This is strange , in my thought it will not affect the end result. Can you try to directly test the flow in Power Automate side? And show the screenshot in your flow run history. 

    And you need to check your connection  in your flow.

    vyueyunmsft_0-1715308513717.png

     

    Best Regards,

    Yueyun Zhang

     

  • Strikerman10 Profile Picture
    13 on at

    I've tested this and this is what I get:

    Action 'Create_file' failed

    The provided workflow action input is not valid.

     

    Strikerman10_0-1715322688325.png

    I tried using a different address to create the file in, but that did not work either. 

     

    I had to change my formula in PowerApps to this to get it to work.  It would not allow me to use your suggestion above where you added, First(DataCardValue22_1.Attachments).Name as it created 3 errors in the formula.  

     

    We expected an operator +, * or & at this point (2 errors) and also Invalid number of arguments, expected 2 received 0-1. 

     

    The formula that was accepted was:

     

    MovetoRejected.Run(
        {
            File: {
                contentBytes: First(DataCardValue22_1.Attachments).Value,
            File: {
                name: First(DataCardValue22_1.Attachments).Name
            }
        }});

     

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi, @Strikerman10 

    You do not need to create the Name parameter in your Power Apps V2 trigger:

    vyueyunmsft_0-1715324765515.png

    You can refer to my first reply and you can try to use this code in your app:
    MovetoRejected.Run(
    {
    File: {
    contentBytes: First(DataCardValue22_1.Attachments).Value,
    name: First(DataCardValue22_1.Attachments).Name
    }
    }
    )

     

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

  • Strikerman10 Profile Picture
    13 on at

    Sorry.  Should have explained that I have tried that, and I receive this error:

     

    Unable to process template language expressions in action 'Create_file_2' inputs at line '0' and column '0': 'The template language expression 'triggerBody()['file']['name']' cannot be evaluated because property 'file' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.


    This is the setup:

    Strikerman10_0-1715355054897.png

     

    I also tried this syntax in your first response but PowerApps would not accept it:

    MovetoRejected.Run(
        {
            File: {
                contentBytes: First(DataCardValue22_1.Attachments).Value,
                name: First(DataCardValue22_1.Attachments).Name
            }
        , First(DataCardValue22_1.Attachments).Name
    )
     
    This gives an error of: Invalid number of arguments, expected 2 received 0-1
     
    Thank you for your help on this.  It is much appreciated. 

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