cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
patty789
Level: Powered On

How to validate a toggle when you click yes you have to add an attachment?

Hello,

 

I have a powerapp form that i am using a toggle with Yes or No. If the user selects yes they need upload an attachement. How can i achive that? Any help will be appreciated. Pic 3.JPG

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: How to validate a toggle when you click yes you have to add an attachment?

Hi @patty789 

I just did a test locally and reproduced your issue. Please use IsEmpty() instead of IsBlank() in the formula.  When I did that on my test app, it worked as expected.

View solution in original post

6 REPLIES 6
Super User
Super User

Re: How to validate a toggle when you click yes you have to add an attachment?

Hi @patty789 

One way to do it using the UpdateContext() function to create a context variable and use it in the Visible property of the Attachments control. In the OnCheck property of the Toggle 

UpdateContext({showattach:true})

and in the OnUnCheck property of the Toggle

UpdateContext({showattach:false})

Change the visible property of the Attachments control to showattach.  In this case, the Attachment control will not be visible unless the Toggle checked. 

To prevent the user from saving a form with the toggle set to Yes and no resume attached, you could set the visible property of the button that saves the form to 

If(Toggle1.Value=true && IsBlank(Attachment1.Attachments),false,true)

 (Assuming the name of the Attachment control is Attachment1.)

Community Support Team
Community Support Team

Re: How to validate a toggle when you click yes you have to add an attachment?

Hi @patty789 ,

 

You could set below formula in the DisplayMode property of the attachment data card:

If(Toggle1.Value=true,DisplayMode.Edit,DisplayMode.View)

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
patty789
Level: Powered On

Re: How to validate a toggle when you click yes you have to add an attachment?

@Drrickryp  Thank you for your response. Howerver i tried that formula you mention below but it did not worked with my test i still can submit the form when i don't attach a resume. pic 4.JPG

 

Super User
Super User

Re: How to validate a toggle when you click yes you have to add an attachment?

Hi @patty789 

You need to put the formula in the Visible property of the Button that submits the form.  That way the button will be hidden if the user sets the toggle to true and there is no attachment in the attachment control.  If the button is not visible it will not be possible to submit your form. Mona's alternative will enable the attachment control but not prevent the form from being saved if nothing is attached. 

patty789
Level: Powered On

Re: How to validate a toggle when you click yes you have to add an attachment?

Hi @Drrickryp  i do have that formula on the visible property on my Submit button that saves the form, but it still saves the form without the attachement being there not sure why it still does not work. Here on the picture it shows that i have selected the Submit button and it shows the formula you provided. Pic 5.jpg

 

Super User
Super User

Re: How to validate a toggle when you click yes you have to add an attachment?

Hi @patty789 

I just did a test locally and reproduced your issue. Please use IsEmpty() instead of IsBlank() in the formula.  When I did that on my test app, it worked as expected.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,329)