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

Toggle in Gallery Causing Trouble with Patch

Hello all,

 

I'm running into a problem that I have no solution for at the moment, so any help is appreciated. I have a gallery connected to an excel spreadsheet in OneDrive. I've added a toggle to the gallery so each of the items has it's own toggle. The toggle identifies active and inactive users. On changing the toggle, two patch commands are triggered.

 

The first updates a record on spreadsheet_A based on the record selected in the gallery. 

The second writes a new record to a change log on spreadsheet_B.

 

This works as expected. My problem is that I have a checkbox the user can click which will filter the gallery to either all users or active users only. When checking or unchecking this checkbox, it triggers the patch commands on the toggle, which writes errant records to the change log. 

 

I'm not sure how to resolve this. Any ideas? Here are my formulas for reference:

 

Toggle - Default:

If(ThisItem.Status="Inactive",false,true)

 

Toggle - OnChange: 

IfError(Patch(Users,LookUp(Users,UserID='User List'.Selected.UserID),{Status: If(('Status Toggle'.Value)=false,"Inactive","Active")}),Reset('Status Toggle'));

IfError(Patch(Change_Log,Defaults(Change_Log),{ChangeId: Last(Change_Log).ChangeId+1, UserId: 'User List'.Selected.UserID, ChangeType: "Update", ChangeItem: "Status", Value: If(('Status Toggle'.Value)=false,"Inactive","Active"), Date: Today(), ChangeBy: User().FullName});Notify("Change log updated successfully!",NotificationType.Information),Notify("Change log failed to update. :(",NotificationType.Error))

 

Gallery - Items:

If(IsBlank(SearchInput.Text),If(varUserFilter=true,Filter(Users, Status="Active"),Users),Filter(Users, SearchInput.Text in FullName ))

 

1 ACCEPTED SOLUTION

Accepted Solutions
Resolver I
Resolver I

I think I figured it out as soon as I posted this. I moved my Patch commands from the OnChange property of the toggle to the OnSelect property so they only trigger when the user physically clicks the toggle.

View solution in original post

1 REPLY 1
Resolver I
Resolver I

I think I figured it out as soon as I posted this. I moved my Patch commands from the OnChange property of the toggle to the OnSelect property so they only trigger when the user physically clicks the toggle.

View solution in original post

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 (26,770)