You can create a separate collection that contains the sorted data and use that collection for your Gallery.
ClearCollect(
SortedData,
SortByColumns(
AddColumns(
Filter(
[@'API Resource Consumers'],
If (
ShowBlankConsumingProductsCheckbox.Value = true,
IsBlank('Consuming Product:ID'),
If(IsBlank(SearchConsumingProductInput.Text), true, SearchConsumingProductInput.Text in 'Consuming Product'.Value)
)
),
"LookupFieldSort", 'Consuming Product'.LookupField
),
"LookupFieldSort", SortOrder.Ascending
)
)
Use SortedData in your Gallery Items Property:
SortedData
In your 'OnChange' method, use 'ThisItem' from the 'SortedData' collection:
Patch('API Resource Consumers', ThisItem, {'Consuming Product': ConsumingProductDropdown.SelectedText})
This way, the 'OnChange' method and the Dropdowns will work with the sorted data and won't conflict with the sorting logic in the Gallery. Adjust the column names and types according to your actual data model.
Thanks!!!
Please consider marking my response as the accepted solution if it successfully resolves your concern. If you found the information beneficial in other aspects, kindly express your appreciation by giving it a thumbs-up.