web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Check Attachments with...
Power Apps
Answered

Check Attachments with Specific Name in the Prefix

(0) ShareShare
ReportReport
Posted on by 2

Hi Everyone,

 

I am working on a case where I have below type of files which needs to be attached and submitted.

 

1. Address Proof

2. ID Reference

3. Educational Certificate

 

I would like to add validation in the form, like if any of the file added in the attachment missing the prefix as above, then the form should not be submitted.

 

For example: If i have added the below files in the attachments field as 'Address Proof - Akshay' & 'ID Reference - Akshay' and the third attachment is missing or not having the prefix as 'Educational Certificate' then the form should not get submitted.

 

Can anyone please help me how to do that please?

 

Warm Regards,

Akshay

Categories:
I have the same question (0)
  • Verified answer
    JohnM86 Profile Picture
    590 on at

    You could try something like: 

     

    If( CountRows(Attachments) = 3, ForAll(Attachments, If( Or( StartsWith(Split(ThisItem.Name, " - ")[0], "Address Proof"), StartsWith(Split(ThisItem.Name, " - ")[0], "ID Reference"), StartsWith(Split(ThisItem.Name, " - ")[0], "Educational Certificate") ), true, Set(varErrorMessage, "Please ensure all attachments have the correct prefix.") )), Set(varErrorMessage, "Please ensure all three attachments are uploaded.") ); If( IsBlank(varErrorMessage), SubmitForm(MyForm), Notify(varErrorMessage) )
     

    This formula first checks if exactly three attachments are uploaded. If not, it sets an error message. If there are three attachments, it uses the ForAll function to loop through each attachment and check if its prefix matches any of the expected prefixes. If any attachment has an incorrect prefix, it sets an error message.

    If there are no errors, the formula submits the form. If there are errors, it displays the error message using the Notify function.

  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @AkshayManke,

     

    Before submitting the form, you could check whether all documents were correctly uploaded (OnSelect of the submit button):

    If(
     //Check if document count = 3 and all documents are correctly prefixed
     //Don't forget to change to the correct DataCardValue / Attachment control name
     CountRows(DataCardValue.Attachments) = 3 && CountIf(
     DataCardValue.Attachments,
     StartsWith(
     Name,
     "Address Proof"
     )
     ) = 1 && CountIf(
     DataCardValue.Attachments,
     StartsWith(
     Name,
     "ID Reference"
     )
     ) = 1 && CountIf(
     DataCardValue.Attachments,
     StartsWith(
     Name,
     "Educational Certificate"
     )
     ) = 1,
     SubmitForm(FormName), //Change FormName
     Notify(
     "Your error message",
     NotificationType.Error
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution.

    Thanks!

  • AkshayManke Profile Picture
    2 on at

    Hello @LaurensM and @JohnM86

     

    Thanks a lot for the help. I will check them out and will get back to you by tomorrow.

     

    Warm Regards,

    Akshay

  • AkshayManke Profile Picture
    2 on at

    Hi @LaurensM & @JohnM86, both the solutions given by you are working. Hence accepting them.

     

    Many thanks for the help !!

     

    Warm Regards,

    Akshay

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard