Skip to main content
Community site session details

Community site session details

Session Id : L5t9vq1gWztvPWxPmTWwoq
Power Automate - Building Flows
Unanswered

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

Like (0) ShareShare
ReportReport
Posted on 2 May 2024 16:03:03 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

  • Strikerman10 Profile Picture
    13 on 10 May 2024 at 15:33:49
    Re: Getting A Filename From SharePoint Document Folder and Creating the File In another Folder using PowerApps V2 trigger

    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. 
  • v-yueyun-msft Profile Picture
    on 10 May 2024 at 07:07:08
    Re: Getting A Filename From SharePoint Document Folder and Creating the File In another Folder using PowerApps V2 trigger

    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 10 May 2024 at 06:51:37
    Re: Getting A Filename From SharePoint Document Folder and Creating the File In another Folder using PowerApps V2 trigger

    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
    on 10 May 2024 at 02:35:30
    Re: Getting A Filename From SharePoint Document Folder and Creating the File In another Folder using PowerApps V2 trigger

    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 09 May 2024 at 10:07:43
    Re: Getting A Filename From SharePoint Document Folder and Creating the File In another Folder using PowerApps V2 trigger

    @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
    on 03 May 2024 at 01:22:23
    Re: Getting A Filename From SharePoint Document Folder and Creating the File In another Folder using PowerApps V2 trigger

    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

     

     


     

     

     

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

Announcing our 2025 Season 2 Super Users!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2