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

Select newest record in an associated gallery when it's created

Hi everyone,

I 'm a beginner on PowerApps (no background as developer) and I (still) have a problem with the application I'm trying to create. The purpose of the application is to manage quotes ("devis" on screenshots) including product lines ("lignes de produits/services").

 

On screenshots:

  • On the left, a gallery (Gallery7) displays the list of quotes
  • On the top right, a detail form (FormViewer2) shows the information of the quote selected in Gallery7
  • On the bottom right, a gallery (Gallery7_3) shows the information of Product lines associated to the quote selected in Gallery7 (and display on FormViewer2)

The workflow is to create a new quote with "+" button (a pop-in appears) and then add one or more Product Lines to that Qote.


My problem is that after creating a new quote, it isn’t automatically selected in Gallery7.

 I read other posts on this forum and I tried to do it with a variable (something close to that: https://blogs.msdn.microsoft.com/carlosfigueira/2017/10/04/decouplingbrowsegalleryfromforms/). It works (information of the last created quote appears in FormViewer2), but product lines don't add up properly: they add to the quote selected when the new quote is created (instead of adding to the newly created quote).

 
Do you have an idea to solve my problem?
 

P.S. : I hope to have been clear. As you have probably noticed, English isn't my native language Smiley Wink


Association betwin multiple product lines and a quote

Form2_2.OnSuccess (create or modify quote form) :
Set(
CurrentSelectionedQuoteRecord;
Form2_2.LastSubmit
)
Icon1_3.OnSelect (adding product line button): Select(Icon3_5);; Relate( CurrentSelectionedQuoteRecord.'Lignes de produits / services'; Patch( 'Lignes de produits / services'; Defaults('Lignes de produits / services'); { mso_name: TextInput2_19.Text; mso_price: TextInput2_18.Text; mso_quantity: TextInput2_17.Text; mso_total: TextInput2_16.Text } ) );; Refresh('Lignes de produits / services');; Reset(TextInput2_16);; Reset(TextInput2_17);; Reset(TextInput2_18);; Reset(TextInput2_19)


Screenshots :
Capture.3.PNG

Capture4.PNG

12 REPLIES 12

the table shows the last records correctly : 

 

Capture11.PNG

 
That's what you asked? I'm not shure 🙂

Hi,

 

Thanks, Could you try

Default:

LookUp(Devis_1; ID=First(SortByColumns(Devis_1; "createdon"; Descending)).ID)

 

ID is a unique field in SharePoint, but in your case it might be QuoteNumber, or whichever field uniquely identifies that row.

 

At this point I think we are missing something very obvious, as my tests that I initially did were able to have that item selected after every submit, regardless of previously selected item.

 

Cheers,

ManCat


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Hi, 

I tried this :

Gallery7.Default : LookUp(Devis_1;'Numéro de Devis'=First(SortByColumns(Devis_1;"createdon";Descending)).'Numéro de Devis')

But it didn't work. There is a warning : "Delegation warning. This part "LookUp" of this formula might not work correctly on large data sets".  But I don't think that's the problem.

Indeed, I tried the same formula on the tab and it worded...

 
I don't understand why it doesn't work. Thank you very much for your help.



 

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (65,183)