SOLVED

Show/Hide Fields Conditionally in SharePoint Online Custom List

Occasional Contributor

Hi,

 

I'm hoping someone can help.

 

I'm aware that fields in an SPO Custom List can be displayed/hidden conditionally via the 'Edit Columns > Edit Conditional Formula' route on the New Form. 

 

This seems to fall down though when a user accesses the Edit Form and changes their original answer to the trigger question. The dynamic questions are re-hidden (as per the conditional formula) but the answers previously provided to the dynamic questions (when they were visible) are retained in the list.

 

I need to find a solution that displays/hides fields conditionally, but that also removes previous responses from the list if the answer to to the trigger question is changed via the Edit Form.

 

If someone has a solution it would be much appreciated.

 

Thanks.          

8 Replies

@Matt9915 Unfortunately, this is the default behavior of SharePoint list forms & conditional formulas. Condition formulas can only show/hide fields based on formula, it cannot remove previous responses/values from list columns.

 

You can use Power apps to customize the SharePoint list forms. Using Power apps, you can show/hide fields as well as remove previous responses/values from list columns based on selections in list form.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Thanks for replying ganeshsanap.

I have been able to find a lot of guidance on the internet around showing/hiding fields using Power Apps, but haven't been able to find anything on removing previous responses/values from list columns based on selections in another column.

Are you able to give me any guidance on how to do this? Or point me in the direction of a forum thread or blog that covers it?
best response confirmed by Matt9915 (Occasional Contributor)
Solution

@Matt9915 You can reset / remove values in one field based on selection of another field (in "OnChange" action) in Power Apps. Refer below threads for more information:

  1. Force field to become blank based on another field's value 
  2. How to clear text input fields? 

Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

That's really helpful. Thanks ganeshsanap

@Matt9915 You're welcome! Glad it helped you.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Hi ganeshsanap,

I'm hoping you're still around! Or maybe someone else can help.

I am still struggling with this issue unfortunately. I can't seem to resolve it by using the onChange property (despite the useful links that ganeshsanap provided).

My scenario is that I have a choice column in my SPO list/Power App that contains just 'yes' and 'no' options. A series of subsequent columns are hidden until the 'yes' option is selected in the choice column. This is working fine.

What I can't seem to figure out is how to reset/clear the value of the subsequent columns if the user re-visits the form and changes their answer to the original choice column from 'yes' to 'no'. This show/hide functionality is re-hiding the columns successfully, but the previous responses are being retained in the SharePoint list.

I have tried applying the following If statement to the 'reset' property of the hidden questions (with DataCardValue17 being the choice question), but this isn't working either. The previous responses still aren't being cleared from the list:

If(DataCardValue17.Selected.Value="No",true,false)

I'm very new to PowerApps so if someone could point me in the right direction I would really appreciate it.

Thanks

@Matt9915 You can reset the other controls in OnChange property of Yes/No controls as per your requirements.

You have to use the Reset() function for this, like: 

 

Reset(TextInput1)

 

Documentation:  Reset function in Power Apps 


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Thanks ganeshsanap. I'm glad you're still around!

I have tried this. On the OnChange property of the choice column I applied:

Reset(DataCardValue24)

DataCardValue24 being one of the subsequent questions. It still doesn't clear that field when the choice column is changed from 'Yes' to 'No' though. It continues to retain the previous answer.

Will this only work on plain text fields? The 3 fields I need to clear 'OnChange' are another choice field, a multi-line text field and a date/time field. Also, can it only be applied to clear one field? I would need to clear all 3 fields if the choice column is changed.

Thanks