cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GarryPope
Impactful Individual
Impactful Individual

Submitting a New Form doesn't show newly created data, but previous record

Hello Power Apps Community,

I hope you can help please, as I'm going around in circles. This post is long, sorry. But wanted to give some context.


In short, when create a new record via a form, how can I make it show the newly created record, and not the record I was previously viewing?

I've created a canvas app in Dataverse for Teams.

I have 2 tables "Employee" and "Transaction". It's a one to many relationship, so 1 Employee can have many Transactions.

 
The process is that on a gallery of Employee records I select one record and pass this information into a gallery of Transactions on another screen. So I see all Transactions for the Employee in the second gallery.
 
In the second gallery that is showing all Transactions, I then want to select a single Transaction record and navigate to a form to show more information about the Transaction. The OnSelect property for the selected records in the Transaction gallery has the below formula.
 
galTransaction.Selected;
Navigate(
          ScreenDetailTransaction,
          ScreenTransition.None
)
 
So I land on the ScreenDetailsTransaction
It has a form called frmDetailTransaction
Its Item property is galTransaction.Selected
 
ScreenDetailTransaction.png
 
If I click the pencil icon to edit the form frmDetailTransaction
Its OnSelect property is below:

Navigate(
          ScreenEditTransaction,
          ScreenTransition.None
)
 
This takes me to another screen called ScreenEditTransaction
This screen has another form on it called frmEditTransaction

Its Item is galTransaction.Selected this might be where I'm having a problem, but who knows...?

Here I make my change to the Transaction record and save.

Its OnSelect property is SubmitForm(frmEditTransaction)

Its OnSuccess property is below

Navigate(
       ScreenDetailTransaction,
       ScreenTransition.None
)

This then submits the changes to the database and takes me back to the screen ScreenDetailTransaction so that I can view the record.
 
This is working perfectly... Now, after all that... The problem I am experiencing is, if you look at the screenshot above, there is a + icon. This is to create a new Transaction record.
Its OnSelect property has the below formula:

NewForm(frmEditTransaction);
Navigate(
      ScreenEditTransaction,
      ScreenTransition.None
)
 
So this takes me to the ScreenEditTransaction
With the form frmEditTransaction
Which I've already stated its properties above.
 
But what happens is when I submit the changes of the new record I'm creating and I navigate back to the ScreenDetailTransaction my newly created Transaction record is not showing, instead the form shows the last Transaction record I clicked on before creating a new record.
 
How can I make the newly created transaction record show in the frmDetailTransaction form once it's been created and not the last transaction I viewed on that form?
 
Any help would be greatly appreciated. I'm sure I'm doing something wrong. It can't be this difficult. Thanks very much. 
 
Garry
1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@GarryPope 

This IS a good place for a variable!

In the OnSelect of the Transaction gallery set the formula to the following:

Set(glbSelectedTransaction, ThisItem);
Navigate(ScreenDetailTransaction, ScreenTransition.None)

Set the Item property of the frmDetailTransaction AND the frmEditTransaction forms to the following:

glbSelectedTransaction

 In the OnSuccess action of the frmEditTransaction form, set the formula to the following:

Set(glbSelectedTransaction, frmEditTransaction.LastSubmit);
Navigate(ScreenDetailTransaction, ScreenTransition.None)

 

This should resolve the issue you are having as your DetailForm was based on the Gallery selected Item and not the new form information (which the OnSuccess formula above will correct).

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@GarryPope 

This IS a good place for a variable!

In the OnSelect of the Transaction gallery set the formula to the following:

Set(glbSelectedTransaction, ThisItem);
Navigate(ScreenDetailTransaction, ScreenTransition.None)

Set the Item property of the frmDetailTransaction AND the frmEditTransaction forms to the following:

glbSelectedTransaction

 In the OnSuccess action of the frmEditTransaction form, set the formula to the following:

Set(glbSelectedTransaction, frmEditTransaction.LastSubmit);
Navigate(ScreenDetailTransaction, ScreenTransition.None)

 

This should resolve the issue you are having as your DetailForm was based on the Gallery selected Item and not the new form information (which the OnSuccess formula above will correct).

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
GarryPope
Impactful Individual
Impactful Individual

Hello @RandyHayes,

I spent the entire day yesterday, almost every hour of that day, trying different things. Thanks so much for your help. You have no idea how pleased I am to have got this last bit solved. I would have never of done it without your help. Also, I see on YouTube you have the PowerApps Form Plus video. I'll be watching that this morning.

 

Thanks again!

Garry 

RandyHayes
Super User
Super User

@GarryPope 

So happy to help out!  I am glad you got past that.  I hope you enjoy that video as well - it is a long one, but packed full of good stuff.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
GarryPope
Impactful Individual
Impactful Individual

Hello @RandyHayes,

Your YouTube video was the best! I learnt more in 2 hours than I have in weeks/months wrestling with forms. You're a brilliant trainer.

Just take a look at my demo form. It's not going to win any beauty contests, but it's super functional. This is going to be my reference app for forms, so when I build a new form I'll come back to it.

 

Ugly Form.png

 

Once again, thanks so much for making this.

Garry

RandyHayes
Super User
Super User

@GarryPope 

Beauty is in the eye of the beholder!!  

I am glad the video was helpful for you.  It's a lot of stuff, but once you get Forms in your mind, it's hard to avoid them.

I will say personally that when I started PowerApps years ago, I avoided the EditForm like the plague.  It seems clunky and there were too many moving parts and I thought I would just build it all myself - better!  That's a developer thinking for ya.  I took off the dev hat and dug in to explore after a while and realized that the form did pretty much everything already that I was spending days trying to make work. 

I will say now that I use the form just about everywhere.  Oddly enough I rarely use the actual form as the interface for users, that I like to design on my own, but I use the form as a base for all the real work (kind of like I did in the video with the W4 form).

 

Keep up the good work!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,155)