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

Toggle settings

I am working on a form which has multiple toggles. Normally by default a toggle is turned off but for a couple of them I have turned them on by setting the default property to ‘true’. When I am in edit mode and I turn off a toggle and then save the form as draft which takes me back to the gallery and then return to the edit mode, the toggle is turned on again. How can I make sure the toggle stays off when saving to draft?

Also when I turn off the toggle a hidden field appears. The visible property of that field is set to false by using the formula If(tglMailVerwijderen.Value=false;true;false) when the toggle is on. When I enter some info in the field and then turn the toggle on again the field becomes hidden again, but I want the text I entered in the hidden field to be deleted. How can I achieve that?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Ewoud ,

OK - I see your toggle must be bound to a field, so you can disregard my previous theory. On the Default of the toggle, you need something like

If(
   YourFormName.Mode=FormMode.New,
   true,
   Parent.Default
)

 

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.

View solution in original post

9 REPLIES 9
WarrenBelz
Super User
Super User

Hi @Ewoud ,

To answer the second question, firstly the formula on the Visible needs to be just

!tglMailVerwijderen.Value

which sets Visible to the opposite of the toggle value. To delete the text, put this on the toggle OnChange

If(
   Self.Value=false,
   Reset(YourTextBoxName)
)

and ensure the Text box Default is Blank() or nothing.

Now to your first question - I assume as you have the toggle Defaults to true or false, they are not bound to any field you have in the form. What do you mean by "Save the form as a draft"? Can you please supply the code you use.

 

Hi @WarrenBelz,

Thanks for you reply.

Let me explain a bit more about my form. The form works with fields that come from a SharePoint list. It is created for offboarding when someone leaves the company. The form can be saved as draft by clicking a button ‘Save as draft’ which will take you back to a Gallery. In that way the form can be edited later by clicking an edit button in the gallery which takes you back to the edit screen. Once the form is complete the submitter can click a button ‘Submit’ which makes the form only readable. The edit button in the gallery then isn't visible anymore. The formula of the OnSelect property of the ‘Save as draft’ button is:

Set(RequiredFields;false);;
UpdateContext({lclStatus:"Concept"});;
SubmitForm(frmNieuweAanvraag);;
UpdateContext({lclStatus:Blank()})

The Toggle Defaults are indeed set to true and not bound to any other field.

The first code you mentioned works perfectly. The second unfortunately not. The field isn’t cleared after I turn the toggle back on again. Maybe it is important to mention that the field is a Person Lookup field from SharePoint.

Hi @Ewoud ,

It is a bit hard to visualize what you are doing, but a couple of things I will mention. Firstly, you are writing back to the list, so it is not really a "draft".

The Toggle OnChange should work on any field and set it back to whatever its Default is - what is happening to yours?

Also any "unbound" controls in a gallery will reset if anything is initiated from the gallery. One solution (if you are using a Collection for the gallery Items) is to add column/s (boolean) and Patch the toggle value to this, so when it resets, it will retain the value.

Hi Warren,

I have added 2 images for a bit more visualisation. One of the Gallery and one of the View/Edit screen. Everything is in Dutch.

The gallery shows some information about the details entered in the form. Also a field Status is available for the end user and the manager of the SharePoint list. Both can therefore see if a form is already submitted or still available as draft. Once a form is submitted not only the SharePoint list gets the status Submitted but also Power Automate is sending some emails and 2 different SharePoint lists are populated with information from the form.

When the toggle 'Mail verwijderen' is off then the field 'Mail doorsturen naar' is visible. I have now selected the Acitive Directory user 'Testewoud'. If I toggle on, then the field 'Mail doorsturen naar' disappears and according to your formula it should delete 'Testewoud'. But when I toggle off again then the field with the value Testewoud appears again. I have set the OnChange propery of the toggle 'Mail verwijderen' to:

If(
   Self.Value=false;
   Reset(DataCardValue17)
)

I am not using collections.

Hopefully this give a bit more of a clear picture of the form.

@WarrenBelz,

Sorry I forgot to mention you correctly in my last reply. Hopefully this will help to get the topic back in your sights :).

Thanks @Ewoud ,

I must have missed your earlier post. As I mentioned, unbound controls in a gallery reset if something is initiated out of the gallery. A couple of choices you have (I use the first)

  1. Save each line as the user edits it (you can use ThisItem.IsSelected as a criteria for displaying the Edit function)
  2. Patch all updated toggle value when they are changed to an added field in a collection forming the gallery Items and default the toggles to this field value.

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.

@WarrenBelz

I found the reason why the toggle was turned on again after saving the form. I changed the Default property of the toggle from Parent.Default to true as I thought that was the way to go to enable the toggle by default. When I set it back to Parent.Default again, it worked normally again.

Only thing is that now by default the toggle is turned off again. Any ideas on how to enable the toggle by default when opening the form for a new input and when turned off, the off setting is saved when saving the form as draft or it is being submitted as final?

Hi @Ewoud ,

OK - I see your toggle must be bound to a field, so you can disregard my previous theory. On the Default of the toggle, you need something like

If(
   YourFormName.Mode=FormMode.New,
   true,
   Parent.Default
)

 

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.

Hi @WarrenBelz

Thanks. This is working perfectly. Now the formula for deleting the box content is also working:

If(
   Self.Value=false;
   Reset(DataCardValue17)
)

Thanks for your patience and help for my issue!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (964)