cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Partisan
Post Partisan

Keep a toggle open

Hello,

 

I have 4 toggle switches in my form (please see attached screenshot). They all default to "No" / false unless they need to be flipped on to record a project that has been placed on hold, cancelled, etc. The reason I did it this way is that I set the date pickers to default to today's date versus Dec 31, 2001 and didn't want to give people the mistaken impression that their project had been put on hold, cancelled, etc. "today".

 

So here is what I could use help with. If I toggle a switch to "Yes" / true and fill in the information (e.g. Negotiated By and Negotiated Date), I want the toggle switch to stay on "Yes" / true and keep showing the fields. Right now, the Default setting for the toggle switch control is Parent.Default so it keeps going back to the "Off" setting when I save the form (the Negotiated By, Negotiation Date and other fields retain their value when changed). What If statement can I enter to keep the toggle on if it needs to be activated and what property do I apply it to? Would it go in OnCheck? I'm kind of hoping so since I also see an OnUnCheck property which would be helpful for undoing an On Hold "true" setting when the hold is lifted. I think that is the only 1 of the 4 that would be undone at some point.

 

Here are the formulas I am using for the Negotiation controls, the rest follow the same pattern.

 

Form OnSuccess property:

Negotiated By

Set(
varNegBy,
Self.LastSubmit.'Negotiated By'
);
Set(
varNegDate,
Self.LastSubmit.'Negotiated Date'
);

 

Negotiated By DefaultSelectedItems property:

If(!IsBlank(varNegBy),varNegBy,ThisItem.'Negotiated By')

 

Negotiated Date DefaultDate property:

If(!IsBlank(varNegDate),varNegDate,ThisItem.'Negotiated Date')

 

The Visible property of the Negotiated By and Negotiated Date datacards is set respectively to:

toggleNegotiate.Value

 

Thanks in advance for your help,

Teresa

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Post Partisan
Post Partisan

Re: Keep a toggle open

@WarrenBelz 

 

Hi Warren,

 

This was a long journey that ended up in a different place than where it started. Dropdown menus ended up being much easier than toggles to work with and my final cascading dropdown solution that includes the ability to default to certain percentages (e.g. Completed = 100%) as well as show/hide fields based on the selected status, ended up being the most comprehensive solution for what I was trying to achieve. I hope you don't mind me sharing this PDF doc with the Community and marking it as the solution. I will kudo all of the tips you gave me along the way that will also be helpful to users. Hopefully, we can save other members of the Community some time with these tips.

 

Thanks again for all of your help and support!

Teresa

View solution in original post

26 REPLIES 26
Highlighted
Super User III
Super User III

Re: Keep a toggle open

Hi @tagustin2020 ,

Are the toggles on the form? If so what is the update property of the cards they are on as they should save back to the list if they are based on a list field (yes/no type).

The other thing is that 31 December 2001 is not the Default - it is the InputTextPlaceholder and you can delete this if you do not want to see anything in the date picker when it is blank.

Also you can use the OnCheck and OnUncheck to automate things if you wish including setting dates in the date pickers.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Highlighted
Post Partisan
Post Partisan

Re: Keep a toggle open

Hello Warren,

 

Yes, the toggles are in the form. Here are the update values for one of the rows. They all have the same types of controls.

 

Negotiated Toggle: Update = toggleNegotiate.Value

Negotiated By People Picker: Update = ddNegBy.Selected

Negotiated Date Calendar Control: Update = calNegDate.SelectedDate

 

The values are saving back to the SharePoint list just fine and the values are retained in the controls. It is just that if someone toggles a switch on, chooses a person and picks a date I want the toggle switch to stick on Yes so the People Picker and Calendar Controls are visible. How do I do that?

 

Thanks for letting me know about the calendar inputtextplaceholder dealy.

 

Teresa

Highlighted
Super User III
Super User III

Re: Keep a toggle open

Hi @tagustin2020 ,

I am a little unclear here, so I will summarise what I understand - using the Negotiated toggle

  • Update on the card is toggleNegotiate.Value and stores this value (Yes/No) in SharePoint fine
  • Default is Parent.Default and should bring the value back into the toggle as saved when open

So the next question is what are the Visible properties of the cards you want shown?

Highlighted
Post Partisan
Post Partisan

Re: Keep a toggle open

Hi Warren,

 

I live in Oregon where we have a lot of wildfires burning at the moment. Not sure if it is the thick blanket of smoke, but my internet is slow and spotty so it might be a day or two before I can get back to the app as I'm having trouble bringing it up. At least there is rain in the forecast.

 

As soon as I can get into the app, I'll look at the Visible properties for the data cards and get back to you. Have a good day.

 

Teresa

Highlighted
Post Partisan
Post Partisan

Re: Keep a toggle open

Hello,

 

I met with the engineers this week to discuss latest progress on the app. We discussed the toggles and decided that if I can show the person and calendar fields as blank vs showing today's date that we do not need to toggle those fields on and off. That all sounded good until PowerApps decided to be difficult. I spent a lot of time yesterday making sure all of the SharePoint column settings and PowerApps datepicker field and datacard settings matched the two date fields that are displaying correctly, but they won't follow suit. Refreshing my datasource, restarting my machine, running app on start, nothing worked so I decided to wait and check it again this morning, but the results are still the same, 2 fields work, the rest don't. I'm attaching 3 screenshots and sample formulas are below. Does this ever happen to you? Does PowerApps sometimes get corrupted? Should I delete my SharePoint date columns which were originally configured to show Today's date by default and re-add them? It seems like PowerApps is stuck on "Today's Date" even though these settings are set to none now. Before I do all of this, I wanted to check with you to see if there is some other setting I am missing.

 

Settings for Completion Date Field that is working correctly:

DefaultDate: If(!IsBlank(varMarkCompDate),varMarkCompDate,ThisItem.'Completion Date')

InputTextPlaceholder: "Select a Date"

OnChange and OnSelect are set to false

 

Settings for Date Placed on Hold Field that is not working correctly:

DefaultDate: If(!IsBlank(varPlacedOHDate),varPlacedOHDate,ThisItem.'Date Placed on Hold')

InputTextPlaceholder: "Select a Date"

OnChange and OnSelect are set to false

 

The Default value for the SharePoint column settings is set to None.

 

Thank you,

Teresa

 

Highlighted
Super User III
Super User III

Re: Keep a toggle open

Hi @tagustin2020 Theresa,

Blank dates - they are not really . . try this

 If(
   Value(varMarkCompDate)>0,
   varMarkCompDate,
   ThisItem.'Completion Date'
)

and (obviously) 

 If(
   Value(varPlacedOHDate)>0,
   varPlacedOHDate,ThisItem.'Date Placed on Hold'
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Post Partisan
Post Partisan

Re: Keep a toggle open

Hi Warren,

 

Thank you for the advice. I tried the formulas in the 3 fields that are still acting up (see yellow highlighted fields in the attached screenshot), but they didn't work. I kind of suspected they wouldn't for the following reason. After I sent my last message to you, I saved and published the app, deleted all existing records and added a new one. As you can see from the attached screenshots, more of the date fields on the Designer Form are displaying the way I want them to and all of the date fields on the Model Shop form are displaying correctly. The ones highlighted in yellow are not even though all settings are identical. At this point, would you agree that I should try deleting those columns from the data source and re-adding them?

 

I also have a question about the person fields. when the form is in edit mode, the field reads "Select Person". I would like it to read that way when the form is in view mode. How do I do that? I tried entering "Select Person" in the NoSelectionText property, but it didn't work.

 

Have a nice evening Warren,

Teresa

Highlighted
Super User III
Super User III

Re: Keep a toggle open

@tagustin2020 ,

One question - how do you set varMarkCompDate and varPlacedOHDate?

Highlighted
Post Partisan
Post Partisan

Re: Keep a toggle open

@WarrenBelz 

 

Hi Warren,

 

I followed your advice to set the variables in the OnSuccess property of the form:

 

Set(
varPlacedOHBy,
Self.LastSubmit.'Placed On Hold By'
);

 

and 

 

Set(
varCancelDate,
Self.LastSubmit.'Cancellation Date'
);

 

Hope that helps,

Teresa

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 (7,496)