cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

When a new record is created, automatically select that record in an associated gallery?

I have 3 forms. Customer Gallery, New Customer and Add Customer Orders.

 

 

Currently, the workflow is - open Customer Gallery, click to create a new customer (takes you to the New Customer screen), enter customer details, save (returns you to the Gallery Screen), click the button against the newly created record to add orders (takes you to the Add Customer Orders screen).

 

Is it possible to set this up such that, once you click to save a New Customer, the app takes you directly to the Add Customer Orders screen for the newly created customer? I guess this would require the ability to set the value in the Gallery but not sure how to go about it.

 

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: When a new record is created, automatically select that record in an associated gallery?

It may be possible to change the selected item in the gallery, but a better solution would be to decouple the form in the new customer screen and the add customer orders screen from the gallery selection. The post at https://blogs.msdn.microsoft.com/carlosfigueira/2017/10/04/decouplingbrowsegalleryfromforms/ has some details on how to do that.

 

To get to your scenario, in the Gallery screen, when navigating to the Add Customer Orders screen you would pass the selected item (ThisItem) to that screen, and that screen would reference that variable.

 

In the New Customer screen, in the OnSuccess property of the form, instead of navigating to the display screen, you would navigate to the Add Customer Orders screen directly, passing the "LastSubmit" (the newly created customer) to that screen, using the same variable name as you did on the gallery screen.

 

View solution in original post

8 REPLIES 8
Community Support Team
Community Support Team

Re: When a new record is created, automatically select that record in an associated gallery?

Hi @PaulD1,

 

Yes, that is possible.

We could configure the Navigate () function under New Customer screen to naviagte to New customer order screen directly, after the Submit() function.

If here you use the form control to submit New Customer record, then we could take use of 

Editform.LastSubmit   property to get the last submitted record.

And if you use the patch() function, then we could get the Last record by the function Last().

First, FirstN, Last, and LastN functions in PowerApps

Editform and display form controls in PowerApps

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Super User
Super User

Re: When a new record is created, automatically select that record in an associated gallery?

Thanks @v-micsh-msft

 

Sorry, I am still struggling with this.

 

I am using an EditForm (not patch).

 

 

I need two routes to the NewCustomerOrder screen.

  1. Coming via the Gallery (a button beside each customer in the gallery takes you to the NewCustomerOrder screen/form whose item property is set to Gallery.Selected)
  2. Coming directly from the New Customer screen (a button submits the entry, navigates to the NewCustomerOrder screen/form whose item property is set to EditForm.LastSubmit)

How can I set up the app so that, if the user clicks from the Gallery, the NewCustomerOrder EditForm is set to Gallery.Selected and if the user clicks from the NewCustomer screen the NewCustomerOrder EditForm is set to NewCustomer EditForm.LastSelected?

 

Thanks

Paul

 

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: When a new record is created, automatically select that record in an associated gallery?

It may be possible to change the selected item in the gallery, but a better solution would be to decouple the form in the new customer screen and the add customer orders screen from the gallery selection. The post at https://blogs.msdn.microsoft.com/carlosfigueira/2017/10/04/decouplingbrowsegalleryfromforms/ has some details on how to do that.

 

To get to your scenario, in the Gallery screen, when navigating to the Add Customer Orders screen you would pass the selected item (ThisItem) to that screen, and that screen would reference that variable.

 

In the New Customer screen, in the OnSuccess property of the form, instead of navigating to the display screen, you would navigate to the Add Customer Orders screen directly, passing the "LastSubmit" (the newly created customer) to that screen, using the same variable name as you did on the gallery screen.

 

View solution in original post

Super User
Super User

Re: When a new record is created, automatically select that record in an associated gallery?

Thanks @CarlosFigueira 

 

That has got me most of the way 🙂

 

I have decoupled my NewCustomerOrder screen from the Gallery and I can now reach my NewCustomerOrder screen from either the gallery (setting a context variable to SelectedItem) or the NewCustomer screens (setting a context variable to EditForm.LastSubmitted).

 

I just have one more hurdle to jump...

 

 

The NewCustomerOrder form is a display form (there are controls under the form for adding the Orders) with datasource OrderHeader. There is a button on this form that navigates to another screen (PayOrder) with an editform, with the same datasource. This is where the user can select a discount and record a payment value.

 

When navigating from the NewCustomerOrder screen, how do I get the EditForm on the PayOrder screen to display the correct record? I cannot use LastSubmit, as I haven't submitted anything and I don't appear to be able to pass the context variable from the NewCustomerOrder screen to the PayOrder screen.

 

Summary: I need to jump from DisplayForm1 to a second EditForm1 (on a different screen) and set EditForm1 to the same record as DisplayForm1. Both EditForm1 and DisplayForm1 have the same Datasource.

Super User
Super User

Re: When a new record is created, automatically select that record in an associated gallery?

Please ignore previous post (can't see a way to remove it).

 

I now have it working - I can indeed pass the context variable from the NewCustomerOrder screen to the PayOrder screen.

 

The context variable in NewCustomerOrder is: displayItem.

 

When I navigate to the PayOrder screen I use the following:

EditForm(frmPayOrder);Navigate(scnPayOrder, ScreenTransition.Fade, {displayItemPayOrder:displayItem})

I then set the Item property for frmPayOrder to displayItemPayOrder

 

Not certain why it didn't appear to be working previously - I must have missed a step or maybe didn't run the app all the way from the first screen (so maybe a variable didn't get set).

 

Cheers

Paul

magikbus
Level: Powered On

Re: When a new record is created, automatically select that record in an associated gallery?

Carlos, Thank you , but this does not work for my application because I need to retrieve the '{Attachments}' field. This field is not carried over to variables that contain a record. I have to somehow tell the gallery to select the newly added list item. Is this possible?

PytByt
Level 8

Re: When a new record is created, automatically select that record in an associated gallery?


@PaulD1 wrote:

Thanks @v-micsh-msft

 

Sorry, I am still struggling with this.

 

I am using an EditForm (not patch).

 

 

I need two routes to the NewCustomerOrder screen.

  1. Coming via the Gallery (a button beside each customer in the gallery takes you to the NewCustomerOrder screen/form whose item property is set to Gallery.Selected)
  2. Coming directly from the New Customer screen (a button submits the entry, navigates to the NewCustomerOrder screen/form whose item property is set to EditForm.LastSubmit)

How can I set up the app so that, if the user clicks from the Gallery, the NewCustomerOrder EditForm is set to Gallery.Selected and if the user clicks from the NewCustomer screen the NewCustomerOrder EditForm is set to NewCustomer EditForm.LastSelected?

 

Thanks

Paul

 


Hi @PaulD1 

 

I have the same exact problem with you. Can you help me with the solution?

What formula should i put in the item property of the editform?

 

thanks,

pytbyt

PytByt
Level 8

Re: When a new record is created, automatically select that record in an associated gallery?


@PaulD1 wrote:

Please ignore previous post (can't see a way to remove it).

 

I now have it working - I can indeed pass the context variable from the NewCustomerOrder screen to the PayOrder screen.

 

The context variable in NewCustomerOrder is: displayItem.

 

When I navigate to the PayOrder screen I use the following:

EditForm(frmPayOrder);Navigate(scnPayOrder, ScreenTransition.Fade, {displayItemPayOrder:displayItem})

I then set the Item property for frmPayOrder to displayItemPayOrder

 

Not certain why it didn't appear to be working previously - I must have missed a step or maybe didn't run the app all the way from the first screen (so maybe a variable didn't get set).

 

Cheers

Paul


Hi @PaulD1 

 

Could you please explain more details about your solution above?

I have tried the same, but it wont work. I think i miss something from the updatecontext side.

 

Please help.

 

Regards,

pytbyt

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,677)