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

I am very conscious that I'm becoming a nuisance Warren. I'm sure you must be equally as frustrated by this issue as me now. Sorry 🙂.

 

As far as the variable is concerned, I have applied your suggested formula to the OnChange property of the trigger question:

 

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

   

I have then added varReset to the default property of a text input field. This field isn't changing from 'false' to 'true' when the trigger is changed from 'yes' to 'no'. I assume it should be?

@Low_Flying_Bird ,

Correct - it should be and if not, none of this will work. Are you sure no does not have a capital  N ?

Thanks Warren. I didn't realise it was case sensitive.

 

Amending the formula to 'No' has resulted in the text input field now tripping to 'true' when the trigger field is changed to 'No'. So we're making progress.

 

It then stays as 'true' when the trigger field is changed back to 'Yes' though. That should trip it back to 'false' assumedly?    

Hi Warren,

 

To try and simplify things, I have created a new SharePoint list and associated App with just 4 columns (to mirror those in my existing app):

 

Column 1 = Trigger column (a choice column with 'Yes' and 'No' as the options)

Column 2 = Associated column (a choice column)

Column 3 = Associated column (a multi-line text column)

Column 4 = Associated column (a date column)

 

Steps:

  • Added the formula below to the OnChange property of the Trigger DataCardValue field (which is successfully changing a text input field to true when the trigger is changed to 'yes'):          
If(
   Self.Selected.Value = "No",
   UpdateContext({varReset: true})
)
  •  Added the formula below to the onVisible property of the Edit Screen:
UpdateContext({varReset: false})
  •   Added the formula below to the Default property of each of the associated DataCardValue fields:
If(
   varReset,
   Blank(),
   ThisItem.fieldname
)
  •   Added the formula below to the Reset property of each of the associated DataCardValue fields:
varReset

 

These seem to be the various steps that you've suggested throughout the thread, but it still isn't working. None of the existing data is being cleared from the associated fields in the form (or the SharePoint list) when the trigger is changed from 'Yes' to 'No'.

 

Hopefully me laying out the steps I've taken above will make it easier for you to spot where I'm going wrong.

 

Thanks again. 

@Low_Flying_Bird ,

I assume you have replaced fieldname with your actual field name, but other than that, the steps are correct other than the Date column should be the DefaultDate and the Choice columns Default should be {Value: Blank()}. I am sorry, but will have to draw a line under this shortly.

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (1,825)