cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

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
Highlighted
Super User
Super User

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
Highlighted
Community Support
Community Support

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.
Highlighted
Super User
Super User

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

Highlighted
Helper III
Helper III

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?

Highlighted
Super User
Super User

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

Highlighted
Helper III
Helper III

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?

Highlighted
Super User
Super User

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
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response 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 (9,108)