cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nisha_18
Frequent Visitor

Validation for attachment field

Hi Team,

 

Has anyone performed validation for the attachment field in PowerApps.

Can anyone help me on How to validate the attachment file name when uploading the image.

Ex: Imagename_ImageNumber

     abc.png_76547
Thanks in Advance!

1 ACCEPTED SOLUTION

Accepted Solutions

You will not be able to validate the file before attaching. My suggestion would be to let the user attach the file and then disable the "Submit" button if the file does not match the criteria. You can also have an error message that is displayed. You could use string manipulation to validate the file name. For example, the 2 formulas below extract the ImageName and the ImageNumber from the last attached file:

First(Split(First(Split(Last(DataCardValue8.Attachments).Name, ".")).Result, "_")).Result

Last(Split(First(Split(Last(DataCardValue8.Attachments).Name, ".")).Result, "_")).Result

 

Here, DataCardValue8 is the attachments control from the form card. THe first "Split" gets the file name by removing extension and the second split obtains file parts. Hope this helps.

View solution in original post

4 REPLIES 4
dinusc
Microsoft
Microsoft

Hello @Nisha_18 ,

Can you please clarify what do you mean by validating? If your goal is to validate the content of a file (for example, ensure that abc.def is a JPEG file) then this is not possible. However, you should be able to validate file extension (for example by making sure the file name ends in ".jpg")

Nisha_18
Frequent Visitor

Hi @dinusc 

Thanks for your time.

My goal is to validate the file name during attachment.
Ex: File name must be  Imagename_ImageNumber.

      abc_7843 or abc.png_7843 like this
 Extension may either .png,.jpg,.jpeg,.svg

Thanks in Advance.

You will not be able to validate the file before attaching. My suggestion would be to let the user attach the file and then disable the "Submit" button if the file does not match the criteria. You can also have an error message that is displayed. You could use string manipulation to validate the file name. For example, the 2 formulas below extract the ImageName and the ImageNumber from the last attached file:

First(Split(First(Split(Last(DataCardValue8.Attachments).Name, ".")).Result, "_")).Result

Last(Split(First(Split(Last(DataCardValue8.Attachments).Name, ".")).Result, "_")).Result

 

Here, DataCardValue8 is the attachments control from the form card. THe first "Split" gets the file name by removing extension and the second split obtains file parts. Hope this helps.

View solution in original post

Nisha_18
Frequent Visitor

Thanks a lot @dinusc

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (52,292)