cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AnthonyRegnier
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
Carsten_Growth
Power Apps
Power Apps

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 

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!

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

 

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. 

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
Helper V
Helper V

Hi guys,

 

Is it possible to get any help?

 

Thanks

Anthony

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,201)