cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Power Automate
Power Automate

How Can I Clear a Gallery Selection

I love using the gallery selection to get values that I will use in my submit and/or patch functions. However, when I come back to the screen after performing my actions, I'd like to screen to start fresh without any selections.

 

How, do I clear the gallery selected items onvisible for my screen?

 

Use Case:

Gallery1 is full of items from data source on screen1

Text1.Text is defaulted to Gallery1.Selected.Value.Field

After the first click on Gallery1 Text1.Text shows the correct value

I submit, and navigate to confirmation screen

I return to screen1

but I want Text1.Text to be blank again

....so I would like to know how to clear the gallery selection

 

Thank you in advance for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: How Can I Clear a Gallery Selection

Easy:

 

Gallery1.Default = DefaultSel

Screen234.OnVisible = UpdateContext({DefaultSel: Gallery1.Selected}); UpdateContext({DefaultSel: {}})

 

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

13 REPLIES 13
Highlighted
Community Champion
Community Champion

Re: How Can I Clear a Gallery Selection

Hi

 

I wish I understand your scenario.

You are mentioning Text1.Text (is that TextBox or TextInput?)

 

Anyway, if you wish (either Box or Input) to be "Clear", then there are several ways:

1. Select Text1.Text, and set the Reset = SubmitButtom. Pressed

- When you click on Submit Button, it will trigger RESET (for Text1.Text) to clear the content of Text1.Text

Or, another option

2. Select Text1.Text, and set the Default = any context variable, say, Default = clearvalue

and set the OnHidden = UpdateContext({clearvalue: false}); UpdateContext({clearvalue: true}).

So, when you navigate away from the Text1.Text screen, it will be updated with "true" to clear the contents.

 

Hope I have answered to the right question.

Have a nice day.

 

hpkeong
Highlighted
Power Apps
Power Apps

Re: How Can I Clear a Gallery Selection

Easy:

 

Gallery1.Default = DefaultSel

Screen234.OnVisible = UpdateContext({DefaultSel: Gallery1.Selected}); UpdateContext({DefaultSel: {}})

 

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

Highlighted
Power Automate
Power Automate

Re: How Can I Clear a Gallery Selection

hpkeong: thank you so much - I will be using your first suggestion for all my "Comments" input text boxes! works wonderfully

rgruian: thank you so much! your suggestion worked wonderfully for my text boxes that are reading selections from the gallery as a default!

 

You guys are awesome!

 

Highlighted
Microsoft
Microsoft

Re: How Can I Clear a Gallery Selection

@rgruian I tried your solution to clear gallery selection. It works but it is also giving error Expected: "CurlyClose". Found: "ParenClose"

 

UpdateContext({GalleryReset:{}})

 

Any help would be much appreciated

Highlighted
Anonymous
Not applicable

Re: How Can I Clear a Gallery Selection


@rgruian wrote:

Easy:

 

Gallery1.Default = DefaultSel

Screen234.OnVisible = UpdateContext({DefaultSel: Gallery1.Selected}); UpdateContext({DefaultSel: {}})

 

I hope this helps.



I'm not getting this;

 

I have a display form with basically the same requirement.

There is no displayform.default property - would I have to do this for each and every card value.default on the form?

Highlighted
Community Champion
Community Champion

Re: How Can I Clear a Gallery Selection

Hi

If you are using display , then you have the select the Card, and this the similar to gallery default.

Please verify. Tq
hpkeong
Highlighted
Anonymous
Not applicable

Re: How Can I Clear a Gallery Selection

I was kind of hoping for a form.ResetForm function there somewhere....I also have custom defaults, so using context variables for defaults makes for a very tedious operation.

 

Not serious, just annoying to have to see old data sit there for a few seconds while it updates with new data.  Sometimes confusing, especially to users.

Highlighted
Community Champion
Community Champion

Re: How Can I Clear a Gallery Selection

Hi @Anonymous

 

As @rgruian mentioned, and shared:

 

Gallery1.Default = DefaultSel

Screen234.OnVisible = UpdateContext({DefaultSel: Gallery1.Selected}); UpdateContext({DefaultSel: {}})

..I would suggest if you can try on Screen234.OnHidden so that it will disappear when you left the screen and on return, it is totally clean.

 

Please try it out.

 

TQ

hpkeong
Highlighted
Anonymous
Not applicable

Re: How Can I Clear a Gallery Selection

Thanks hpkeong, but either I'm missing something, or you're missing something.

 

You're talking about a Gallery, I'm talking about a display form.

As far as I'm aware, there is no Default property for a display form at the form level...there are only default properties for each card and value.  Typically the card is set to ThisItem.ColumnName and the value is set to Parent.Default (parent being the card)

 

ThisItem is the Item selected by the Gallery on another page.

It's not the Gallery I want to clear, it's the Display form.

 

I could possibly do this for each card value and set a context variable for the default - I'm pretty sure it would work much like the gallery default as per your example, but I haven't bothered testing that because it's tedious and messy.  While I'm only showing about eight display fields, I have about twenty to choose from.  I don't want to have to do this for each field I add or remove and add again....

 

This might be one for the ideas forum - form-level default for all cards, or simply the ability to reset the form (which currently only works on edit forms, not display forms)

 

Kind regards,


R

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

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 designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,835)