cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rubber_Duck
Regular Visitor

Canvas App - Clear Fields Based on Choice Column Answer

Hi all,

 

I'm very new to PowerApps, so I'm helping someone can help me.

 

I have a Canvas App built from a SharePoint Custom List. The app contains a choice field, which includes only two options - 'yes' and 'no'. A number of subsequent fields (another choice field, a multi-line text field and a date/time field) are set to only become visible when the 'yes' option is selected in the initial choice field. This is working fine.

 

The problem I have is finding a method of clearing/resetting the three subsequent fields if the user later edits the form and changes the initial choice field to 'no'. The subsequent fields are being re-hidden successfully in this scenario, but they still contain the data from the initial submission. 

 

I've tried using an If condition to change the Reset property on the subsequent fields to 'true' when the value of the initial choice field is 'no', but this doesn't seem to work. 

 

This is stopping me from being able to use the app, so if someone can help me solve it it would be big help.

 

Thanks.     

34 REPLIES 34
phipps0218
Memorable Member
Memorable Member

Reset(fieldName) or use a variable and set the variable to blank.

 

Please accept this as a solution.

WarrenBelz
Super User
Super User

Hi @Rubber_Duck ,

Change the Reset of the controls you want cleared to a Variable (I will use varReset) and then on the OnChange of the first control,

If(
   Self.Selected.Value = "no",
   UpdateContext({varReset: true})
)

Also at Screen OnVisible

UpdateContext({varReset: false})

The Default of these controls should be

If(
   varReset,
   Blank(),
   ThisItem.FieldName
)

if you are displaying existing information in them.

 

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

 

 

Rubber_Duck
Regular Visitor

Thanks Phipps. 

 

I've tried the Reset(fieldName) approach. It doesn't work. The fields don't clear/reset.

 

I'm not experienced with variables unfortunately. Could you explain how this would need to be done?

   
 

Corissandageri
Responsive Resident
Responsive Resident

Assuming you are not using a form, and using TextInput or and a dropdown, you could have !Toggle in the Reset property of either the TextInput or Dropdown. This is also assuming you are using a Toggle for the yes no choice column.

@Rubber_Duck ,

Please see the code I posted regarding the Variable setting and Reset property

 

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

Thanks for the advice Warren.

 

I don't really understand your final two steps though I'm afraid. My lack of experience with Power Apps and variables I think!

 

I'm not sure what Screen OnVisible is? And I don't really follow the final step about the default - which controls are you referring to there?

 

Thanks

  

 

 

@Rubber_Duck ,

If you do not select anything (just the screen open), you can get the OnVisible property in the top left drop-down.

If you select the control you want to hide, the Reset property is also in this drop-down, as is the Default.

The actual Default property will depend on what it is now and what type of control it is.

 

 

Ok thanks. I'm getting seriously confused though.

 

Surely it should be as simple as using the OnChange property on the initial choice field to reset the subsequent DataCardValue fields to blank. I don't understand why that doesn't work and it needs variables and default properties based on field types.     

@Rubber_Duck ,

I was simply giving you another option when you said yours did not work. Resetting a control will cause it to revert to its Default value, so if that contains an existing field value from a data source, it will not clear it. The Reset property of a control does the same thing, but will activate when a condition (in this case a Variable) changes to true. The conditional Default property then allows it to clear if the Variable is true.

 

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,221)