Skip to main content
Community site session details

Community site session details

Session Id : AlQiVHXQ9MhIhJJfb2I8a2
Power Apps - Building Power Apps
Answered

Check attachment control if it is an excel file

Like (0) ShareShare
ReportReport
Posted on 24 Nov 2022 09:06:00 by 125

Hi Folks!

 

I want to set an If Statement every time a user attach a file and check it it is an excel file it will trigger a power automate code.

  • Verified answer
    WarrenBelz Profile Picture
    148,951 Most Valuable Professional on 24 Nov 2022 at 21:20:45
    Re: Check attachment control if it is an excel file

    @philifova ,

    That is a completely different question and not straight-forward (it would be quite easy using the last attachment as I posted earlier).

    This was a brain-bender and my best effort is below (and I cannot test it beyond it being valid code) - it should set your Variable to the content of the last attachment with an Excel extension

    With(
     {
     wExt: 
     ForAll(
     AttachControlName.Attachments,
     {
     Ext: 
     Last(
     Split(
     Name,
     "."
     )
     ).Result
     }
     )
     },
     With(
     {
     wPos: 
    		 ForAll(
     Sequence(CountRows(wExt)),
     Patch(
     Last(
     FirstN(
     wExt,
     Value
     )
     ),
     {RowNo: Value}
     )
     )
     },
     Set(
     varAttachment,
     Index(
     AttachControlName.Attachments,
     LookUp(
     Sort(
     wPos,
     RowNo,
     Descending
     ),
     Ext = "xlsx"
     ).RowNo
     ).Value
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • philifova Profile Picture
    125 on 24 Nov 2022 at 12:30:27
    Re: Check attachment control if it is an excel file

    @WarrenBelz 

    It worked but, it's not picking up the current location of excel file. Here the code.

     

    philifova_1-1669292998798.png

     

     

  • WarrenBelz Profile Picture
    148,951 Most Valuable Professional on 24 Nov 2022 at 11:55:34
    Re: Check attachment control if it is an excel file

    Hi @philifova ,

    You asked for every time a user attach a file - so that checks them as they attach. You would have to run this before you save the form

    If(
     CountRows(
     Filter(
     AttachControlName.Attachments,
     Last(
     Split(
     Name,
     "."
     )
     ).Result = "xlxs"
     )
     ) > 0,
     RunYourFlow . . .

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

  • philifova Profile Picture
    125 on 24 Nov 2022 at 11:39:11
    Re: Check attachment control if it is an excel file

    Hi @WarrenBelz 

     

    The user have ability to attach multiple files at the same time. They can also attach a PDF file. I tried the code you provided. It didn't trigger the flow it is because the excel file is in the second row.

  • WarrenBelz Profile Picture
    148,951 Most Valuable Professional on 24 Nov 2022 at 11:22:01
    Re: Check attachment control if it is an excel file

    Hi @philifova ,

    Something like this OnAddFile

    If(
     Last(
     Split(
     Last(Self.Attachments).Name,
     "."
     )
     ).Result = "xlsx",
     RunYourFlow

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

     

     

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473