cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dmc_103
Helper II
Helper II

Validation for attachment control

Hi everyone,

Newbie here. I would like to have a checkbox ticked once the file attached has a .PDF extension. How to better accomplish this one?

Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
rubin_boer
Super User
Super User

 

 

hi @dmc_103 

you can do that as well. just remember you will have to get the first item like this:

If(Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3) = "pdf",true,false)

 

rubin_boer_0-1612676407026.png

If this post helps you in a lot or a little, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

 

View solution in original post

7 REPLIES 7
rubin_boer
Super User
Super User

Hi @dmc_103 

 

Add a gallery and assign its Items = AttachmentDatacard.Attatchments

add a label and a checkbox to the gallery

the label Text = ThisItem.Name

the checkbox Default = If(Mid(ThisItem.Name,Find(".",ThisItem.Name)+1,3) = "pdf",true,false)

 Once the files are uploaded this is what you get

 

rubin_boer_0-1612635489745.png

 

hope it helps

If this post helps you in a lot or a little, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

 
dmc_103
Helper II
Helper II

Thank you @rubin_boer ! before creating what you have suggested though, followup question. Do I still need to create a gallery if my maximum attachment is only limited to 1 (file)?

rubin_boer
Super User
Super User

 

 

hi @dmc_103 

you can do that as well. just remember you will have to get the first item like this:

If(Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3) = "pdf",true,false)

 

rubin_boer_0-1612676407026.png

If this post helps you in a lot or a little, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

 

View solution in original post

dmc_103
Helper II
Helper II

Ah, it did work. However, I want to use the existing checkbox outside the gallery. The checkbox already has an existing string for Default and would just like to add another condition: when .PDF is uploaded in the attachment, checkbox is ticked.😁

dmc_103
Helper II
Helper II

Sorry forgot to mention @rubin_boer  that I tried adding (&&) your suggested IF condition in my existing checkbox's DEFAULT, no squiggly lines but doesn't seem to work.

rubin_boer
Super User
Super User

hi @dmc_103 

 

Can you please share the existing string in default.

 

In the image below the checkbox in the control reference is in a gallery and the gallery is set to the attachments of the datacard hence the Thisitem.Name. The checkbox outside of the control have the default as "

If(Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3) = "pdf",true,false)" which references the actual datacard and not "ThisItem".

rubin_boer_0-1612698175000.png

PS

You can add the current string in the

If(

  (Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3) = "pdf") && (Another condition here),
  true,
  false
)

 
dmc_103
Helper II
Helper II

Hi @rubin_boer , Using your string alone worked, but when I add the existing string: (TextInput1.Text = "Priority"), true, false) - both strings do not work..weird.

So I tried taking out "(" and ")" when adding the existing string, like this: 

If(

  (Mid(First(DataCardValue20.Attachments).Name, Find(".",First(DataCardValue20.Attachments).Name)+1,3= "pdf") && TextInput1.Text = "Priority",
  true,
  false
)

- no squiggly lines but the string for the data card doesn't work. 

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

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (12,227)