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

Use a toggle to change a field

Hi,

 

I want to add a Toggle to change a field from Y to N.

I'm new to PowerApps need some help filling all the necessary function fields

1 ACCEPTED SOLUTION

Accepted Solutions

I'm not exactly sure what you want to do but you would need to use the default property of the toggle. The usual is parent.default.

View solution in original post

17 REPLIES 17
Power Apps
Power Apps

Hi,

 

do you mean changing the content of a Label from Y to N ?

in that case you can do that easily by changing the text rule of the label to something like this

 

If (Toggle1.Value, "Y", "N")

where Toggle1 is the name of the toggle control

No,

 I want to use the toggle to change a data field in the data source from N to Y.

 

Thanks

Hi @NigWatson,

Set Toggle properties

OnCheck - Patch(datasource,baserecord,{datafield:”Y”})

OnUncheck - Patch(datasource,baserecord,{datafield:”N”})

baserecord would be be something like LookUp(datasource, ID=Gallery1.Selected.ID) or 

LookUp(datasource, ID=ThisItem.ID) if the toggle was inside a gallery.

Thanks Drrickryp,

 

But I don't understand baserecord

 

Could you please explain  LookUp(datasource, ID=Gallery1.Selected.ID) ?

The patch function consists of three components: the datasource being patched,  the base record being edited and the item being changed. It would be helpful if you could post a screenshot of the screen where you are placing the toggle so I could better explain it to you.  If you want to visualize it imagine a spreadsheet that contains a Table, thats the datasource.  The row inside of the table is the base record and the field in that row is the datafield.  Please watch the You Tube about the Patch function to understand how it works. 

In your case, I want to use the toggle to trigger the Patch function and make the change you want in your datasource.  

Hi Drrickryp,

Here are shots of the App's edit screen and it's data source:

 

EditScreen.png

 

DataSource.png

 

 

 

Ok, This looks like it could be from an app developed from an Excel spreadsheet, Is that correct?  If  you are using an edit form, then you won't need to use the Patch function.  Please post a screenshot where you mouse over the red x so that I could see the error message you are getting.

Yes, that's correct the app was generated from a speadsheet.

Here's the error message.

error.png

Ok get out of preview mode by hitting f5.  Then click on the card containing the toggle but not the toggle itself.  Open the dropdown box in the upper left hand side of the screen and find the Update property.  Please let me know what it says.  

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (96,778)