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

Navigating from edit screens

I have a canvas power app, Gallery >> display screen >> edit screen.

 

On the edit screen I have a Cancel button

ResetForm(faultInput);Navigate(FaultDetailScreen,Cover)

and a Save data Button

SubmitForm(faultInput);Navigate(FaultDetailScreen,Cover)

 

The Cancel button moves back to the display screen and shows the selected record. But the Save button moves back to the display screen and shows the record at the top of the gallery.

 

Any suggestions please

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@judithPA 

No, in your current formula you are assigning a number (the ID) to that variable.  It is better to just work with the entire record rather than just a portion of it - it will save you from lookups later on.

 

If you have something outside of what I've suggested changing that relies on the IntfaultID, then just leave that alone and change to use the glbCurrentRecord variable as I provided.

_____________________________________________________________________________________
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

RandyHayes
Super User
Super User

@judithPA 

You would just need to reference the proper column of the record in your formula.

It would be:

    Filter(faultEquipment, faultIDE = glbCurrentRecord.ID)

 

This is the same as the .Selected  When you reference .Selected, you are referencing a record.  And, if you append that with .ID, then you are referencing the ID column.  SO, in the case of the variable with the record, you would do the same.

_____________________________________________________________________________________
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

8 REPLIES 8
Nogueira1306
Super User
Super User

What do you want to do with the save button?

I did not understand..

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,

Gonçalo Nogueira

Check my LinkedIn!

Buy me a coffee!

Check my User Group (pt-PT)!

Last Post on Community

My website!

RandyHayes
Super User
Super User

@judithPA 

When you use the SubmitForm function, you should have no other functions after that.  Use the OnSuccess and OnFailure actions of the form to determine the next steps.

 

So, your Save button OnSelect formula should be:  SubmitForm(faultInput)

And your OnSuccess formula should be:  Navigate(FaultDetailScreen,Cover)

 

However, that is not your issue so much that you are seeing - that is more of a "don't do this" type of thing.

 

Your problem is that your detail screen is basing its record off of a gallery.  Most likely in your detail screen you have a GalleryX.Selected somewhere.  If it is a Form on that screen, then it is the Item property of that form that has that formula.

And specifically, the problem is that your gallery is getting updated when you submit the form.  The reason it is updated is because you are changing the datasource with your form submit.  Normally this is not an issue with a simple Items property on that gallery, but if you are doing any sorting or data shaping in the Items property of the gallery...it will re-evaluate the formula and your top record will get selected.  That means your display screen will now show that record instead of what you expect.

 

The fix to this is to establish a snapshot variable of the selected record when it is selected in the gallery.  So, in your OnSelect formula for the gallery or the control in the gallery that takes the person to the detail and edit forms, add a Set(glbCurrentRecord, ThisItem)

Then set the Item property of your forms to glbCurrentRecord

 

And finally, in your OnSuccess action of the form, in addition to the navigate, change it to the following:

Set(glbCurrentRecord, Self.LastSubmit);
Navigate(FaultDetailScreen, Cover)

 

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!

When I go to the edit screen from the display screen i use

EditForm(faultInput);Set(IntfaultID,BrowseGallery1.Selected.faultID);Navigate(FaultEdit,Cover)

to select the correct record.

Can I use this to make the return from the edit screen to the display screen.

I am not sure I understand what the to do with this in the Set(   ) command

Set (IntfaultID, Self.LastSubmit)

Thanks for the pointers and I will separate the Success and Navigate.

RandyHayes
Super User
Super User

@judithPA 

No, in your current formula you are assigning a number (the ID) to that variable.  It is better to just work with the entire record rather than just a portion of it - it will save you from lookups later on.

 

If you have something outside of what I've suggested changing that relies on the IntfaultID, then just leave that alone and change to use the glbCurrentRecord variable as I provided.

_____________________________________________________________________________________
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!

That sounds a better idea, I will give it a go now. Thanks so much.

Fantastic, THANK YOU

All working fine now on the gallery to display then to edit screen. However I am struggling a bit as I also have another option from the display screen to add multiple equipment items. This is a gallery and I don't know how to filter the equipment items to the selected main record.

 

I previously used 

Filter(faultEquipment,faultIDE=BrowseGallery1.Selected.faultID)

which seemed to work but now moving to the global variable I tried 

Filter(faultEquipment, faultIDE=glbCurrentRecord)

in the Items property of the gallery form but the comparison is not valid. I seem to be comparing a record to a value. How can I pick records in the table faultEquipment where the field faultIDE = the value of the field faultID in the master record table faultLive.

Thanks

RandyHayes
Super User
Super User

@judithPA 

You would just need to reference the proper column of the record in your formula.

It would be:

    Filter(faultEquipment, faultIDE = glbCurrentRecord.ID)

 

This is the same as the .Selected  When you reference .Selected, you are referencing a record.  And, if you append that with .ID, then you are referencing the ID column.  SO, in the case of the variable with the record, you would do the same.

_____________________________________________________________________________________
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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,264)