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

Navigate and Back problem because of gallery sorting

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!

6 REPLIES 6
Highlighted
Power Apps
Power Apps

Re: Navigate and Back problem because of gallery sorting

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 

Highlighted
Helper V
Helper V

Re: Navigate and Back problem because of gallery sorting

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!

Highlighted
Helper V
Helper V

Re: Navigate and Back problem because of gallery sorting

@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?

 

Highlighted
Power Apps
Power Apps

Re: Navigate and Back problem because of gallery sorting

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. 

Highlighted
Helper V
Helper V

Re: Navigate and Back problem because of gallery sorting

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

Highlighted
Helper V
Helper V

Re: Navigate and Back problem because of gallery sorting

Hi guys,

 

Is it possible to get any help?

 

Thanks

Anthony

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,865)