web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Navigate and Back prob...
Power Apps
Unanswered

Navigate and Back problem because of gallery sorting

(0) ShareShare
ReportReport
Posted on by 252

Hello everyone, 

 

I have an issue when wanting to navigate or just go back.

I have a stock management app and the gallery sorts the item based on the lowest amount on top versus the highest on the bottom (screenshot attached). Sorting code is the following in case you need it:

 

 

Sort(
 AddColumns(
 Filter(
 'Stock Management',
 StartsWith(
 Title,
 TxtIn_AllProductsSearchBox.Text
 ) &&
 (
 Description = DpDwn_AllProducts.Selected.Result || 
 DpDwn_AllProducts.Selected.Result = "All"
 ) &&
 (
 Status = "High" || 
 Status = "Low" ||
 Status = "Average" ||
 Status = "Out"
 )
 ),
 "SortRank",
 (Stock/Threshold)
 ),
 SortRank,
 If(
 SortDescending1,
 Descending,
 Ascending
 )
)

 

 

The problem I have is the following:

When I open a product to add or remove some stock (let's say I bought 5 so I'll add 5 to the current stock value with a Patch command). Once I validate, the stock changes higher or lower, which update the sorting of my gallery. The screen then automatically shift to another product: the one that falls now in the gallery position where the product I was editing was (that is not the same anymore since I changed the stock  and then the sorting happened - follow me :)?.

 

Code of the "Save" button of my productdetail form:

 

 

Patch(
 'Stock Management',
 First(Filter('Stock Management',Name=Gallery_AllProducts.Selected.Name)), 
 {Stock:Value(Lbl_NewStockResult.Text)}
);
UpdateContext({Quantity: Blank()});
Reset(TxtIn_Qty);
Navigate(StockUpdatedScreen,ScreenTransition.Fade)

 

 

I have a quick workaround: I've created a simple screen "Stock updated Successfully" to which I navigate once I hit save - and then it as only one big button that navigates me back to the gallery... 

 

Code of the Stock updated successfully button:

 

Navigate(ProductsScreen,ScreenTransition.Fade)

 

 

What I would like is:

To keep the "Stock updated Successfully" screen (cause it's nice), but once press its button, that it takes me back to the product I was editing... Knowing that, I have 2 galleries on the same screen that show 2 categories of products (I hide/unhide galleries with a button).

 

Thank you in advance everyone! Hope we get some good findings!

Retired product gallery.png
Save stock.png
Main gallery.png
Categories:
I have the same question (0)
  • Carsten_Growth Profile Picture
    Microsoft Employee on at

    You can also navigate using 

    Navigate( Screen [, Transition [, UpdateContextRecord ] ] )

    with the UpdateContextRecord you can "forward" the ID of the record that you´re editing/modifying - up until the success screen and therefore then navigate back to the gallery screen by forwarding the context and filtering based on this. That would leave the user under the impression it left where he/she started 

  • AnthonyRegnier Profile Picture
    252 on at

    Hey @Carsten_Growth !

     

    That sounds quite promising let me crack on that now!

    So just to make sure, I shall just add "UpdateContextRecord" in the navigation formula of my save button, then on my save button just have "Back()" ? Am I right?

     

    Thanks!

  • AnthonyRegnier Profile Picture
    252 on at

    @Carsten_Growth  I think I understand, I just struggle a bit with the formula.

    I know the third argument of navigate uses context variable but how can I embeed the product ID there, and use a look up to navigate back there?

     

  • Carsten_Growth Profile Picture
    Microsoft Employee on at

    You can set your product ID selected as context variable. 

    UpdateContext( { ShowLogo: true } )

    Would set a ShowLogo to be true, if I would now assign ShowLogo to the visibility of a control on the screen I am navigating to, this control would become visible. Same with your product ID that you could "transport" to your first screen and then use this inside your filter of the gallery to filter again on the product ID given. That way as said the user would think it left what was selected when navigating away. 

  • AnthonyRegnier Profile Picture
    252 on at

    Hi @Carsten_Growth 

     

    Thanks for the second explanation. I understand what you are suggesting. I have tried all day without success, I manage to have a button that appears and hides when I hit save instead of navigating to that other screen, but navigating back to the product with a context variable to look it up, I wasn't able. I'm still rather new to PowerApps.

     

    A little bit more help would be more than welcome, if you don't mind of course...

     

    I tried to inspire myself from the code I use for my form to look at a product detail:

    Screen: ProductDetailsScreen

    Form: Form_ProductDetails

    Property Item: 

    LookUp(
     [@'Stock Management'],
     ID = If(
     vRetired,
     Gallery_RetiredProducts.Selected.ID,
     Gallery_AllProducts.Selected.ID
     )
    )

     

    The button I have is just having a variable under its Visible property that I switch to true or false so far...

     

    Thank you in advance

    Anthony

  • AnthonyRegnier Profile Picture
    252 on at

    Hi guys,

     

    Is it possible to get any help?

     

    Thanks

    Anthony

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 136 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard