cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stephenkln
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
stephenkln
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
stephenkln
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.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,788)