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

Toggle visible and refresh data in fields.

Hi everybody;

I want to make a toggle to hide/unhide some cards on a form and refresh data in these cards to default or blank if it unchecks.

Screen Shot 2019-11-05 at 10.17.22 AM.png

How can I do that?

1 ACCEPTED SOLUTION

Accepted Solutions
Eelman
Level 10

Re: Toggle visible and refresh data in fields.

@carem the If() statement will sit in the Default property of each card, eg

 

I assume your DataCards default values look something like:

eg. DataCard.Default = ThisItem.'Child age'

 

Change it to:

DataCard.Default = If( !varHide, Blank(), ThisItem.'Child age')

If you are not yet aware, you need to unlock each datacard before you can change any of their properties.

 

Also, when I had a quick play with hiding datacards, when I hid an entire row/line the line below moved up. That's going to get a little messy to control - and don't ask me how to do it - please 🙂

 

Also, when I tested I used two variable, one for each line. I think that may work better?

View solution in original post

6 REPLIES 6
Community Support Team
Community Support Team

Re: Toggle visible and refresh data in fields.

Hi @carem ,

 

Set the OnUncheck property of each toggle controls to:

ResetForm(FormName)

 

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.
Eelman
Level 10

Re: Toggle visible and refresh data in fields.

For hide/unhide use a variable:

 

Hide: Toggle.OnUnCheck = UpdateContext({ varHide: false })

Unhide: Toggle.OnCheck = UpdateContext({ varHide: true })

 

then for any datacards you wish to hide/unhide

DataCard.Visible = varHide

 

Follow Sik's comment for the refresh

carem
Level: Powered On

Re: Toggle visible and refresh data in fields.

@v-monli-msft @Eelman 

I don't want to refresh entire form. I want to set the value or text of fields invisible from switch toggle become 0 or blank.

Example above:

I want when I switch the first toggle: All the fields in the first line invisible and set the value of that field to 0/blank.

Similar to the 2nd line.

How I can do that?

Eelman
Level 10

Re: Toggle visible and refresh data in fields.

@carem my comment will work for your hide/unhide part

 

for the reset, are the default properties of your DataCards 0/blank? If so, you could add the Reset() function to my above OnCheck code like this:

 

Toggle.OnCheck = [above code ] ; Reset(DataCard1); Reset(DataCard2) ...

 

If the datacard values are not 0/blank then you'll likely have to create an If() statement

carem
Level: Powered On

Re: Toggle visible and refresh data in fields.

@Eelman 

Reset() function will work perfect if the form is in New Mode.

But if the Form is in Edit Mode, Reset() will return the default value of this item, it's mean it will return the old data of these fields.

Can you give me more information about the approach with "if statement" you mention above?

Eelman
Level 10

Re: Toggle visible and refresh data in fields.

@carem the If() statement will sit in the Default property of each card, eg

 

I assume your DataCards default values look something like:

eg. DataCard.Default = ThisItem.'Child age'

 

Change it to:

DataCard.Default = If( !varHide, Blank(), ThisItem.'Child age')

If you are not yet aware, you need to unlock each datacard before you can change any of their properties.

 

Also, when I had a quick play with hiding datacards, when I hid an entire row/line the line below moved up. That's going to get a little messy to control - and don't ask me how to do it - please 🙂

 

Also, when I tested I used two variable, one for each line. I think that may work better?

View solution in original post

Helpful resources

Announcements
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

Top Solution Authors
Top Kudoed Authors
Users online (4,565)