cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Husk457
Level: Powered On

Edit form returns to correct record but returns to incorrect record when submitting form

Hello,

 

I am new to powerapps and forums to that matter.I have searched but cannot find the issue after trying advice on posts. Any help will be greatly appreciated.

 

I have four screens linked to an Excel spreadsheet. First screen groups data by a six digit number, it then goes through to a second screen that lists all records matching the selection.

 

Then moves to a detail form of the single record. . Then I hit an edit button EditForm(EditForm);Navigate(Screen3_1, ScreenTransition.None) which pulls the record through. All good to here,

 

The issue that I can not fix is in edit mode I have two buttons ResetForm(EditForm);Back() - returns me tow the current selected record. But if I press the button SubmitForm(EditForm);Back(). The alterations are saved but it returns to the wrong record?

 

Please could someone advise me on what I have done wrong. I hope the message is clear and thankyou for taking the time to read.

 

Kind regards,

 

Husk457

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Edit form returns to correct record but returns to incorrect record when submitting form

Hi @Husk457,

 

Could you please share a bit more about your app's configuration?

Further, could you please share more details about the Display form within your Detail Screen (third screen) and Edit form within your forth screen (Screen3_1)?

 

Please check if the Item property of the Display Form within third screen and the Edit Form within forth screen are both set to following formula:

BrowseGallery5.Selected

Note: The BrowseGallery5 represents the Gallery control within your second screen.

 

In addition, I agree with @dinusc's thought almost. I think there may be something wrong with the GroupBy function within the formula that you provided.

 

The GroupBy function returns a table with records grouped together based on the values in one or more columns. Records in the same group are placed into a single record, with a column added that holds a nested table of the remaining columns.

 

Please take a try to remove the GroupBy function from your formula that you provided and modify the Items property of BrowseGallery4 control as below:

SortByColumns(Search(WorkList,TextSearchBox4.Text,"CNumber"),"CNumber")

Then check if the issue is solved.

 

More details about the GroupBy function in PowerApps, please check the following article:

GroupBy function

 

 

Best regards,

Kris

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
Microsoft Employee

Re: Edit form returns to correct record but returns to incorrect record when submitting form

Hello Husk 457,

Try the following:

MyResetButton.OnSelect=SubmitForm(EditForm)

MyEditForm.OnSuccess=Back()

Husk457
Level: Powered On

Re: Edit form returns to correct record but returns to incorrect record when submitting form

Hi dinusc,

 

Thank you for your responce. Unfortunity the suggestion did not alter the result. I am very green to PowerApps and porbably miles off! But on the main screen I have a groupby formula and the last aurgument is group name. Which I have not used and do not know what it is there for?

MAIN SCREEN

BrowseGallery4.Items =

SortByColumns(Search(GroupBy(WorkList,"CName","CNumber","Description"),TextSearchBox4.Text,"CNumber"),"CNumber")

 

The following formula in the browsegallery items on the next screen shows the individual records of the above items listed. The Selection is a varible created buy some buttons to select filtered items from the list.

 

SECONDRY SCREEN

SortByColumns(Search(Filter(WorkList,CNumber = BrowseGallery4.Selected.CNumber),Selection,"InternalExternal"),"Complete",Descending)

 

From there it goes into a detailform and then an edit form. 

 

My gut feeling is I might of not handeld the events efficiently and create a problem further down the track? 

 

Again, thank you for you help. I might have written some poor formulas?

---------------------------------------------------------------------------------------------------------------------------------------------------------------

I have done some more investigating. I set it up using a create app from onedrive feature I have then created another screen to groupby the information then have tried to pass that through to the old main screen and continued through to detailform then editform. By adding the screen to the start of the app it is causing the selection of the wrong record after the form is submitted. All other events seem to be working as it should. I hope that my error is more obvious?

 

Kind regards and thank you.

 

Husk457

Microsoft Employee

Re: Edit form returns to correct record but returns to incorrect record when submitting form

The "GroupBy" function allows grouping certain records by specified criteria. Please see this page for more information.

I suspect that you do not need goruping at all here. The reason I think so is because you assign the formula to your gallery directly (as opposed to building a collection) and you would really have to configure your gallery in a certain way (to show subgorups) in order to take advantage of it.

Please try removing that function and see if you see any issues.

Community Support Team
Community Support Team

Re: Edit form returns to correct record but returns to incorrect record when submitting form

Hi @Husk457,

 

Could you please share a bit more about your app's configuration?

Further, could you please share more details about the Display form within your Detail Screen (third screen) and Edit form within your forth screen (Screen3_1)?

 

Please check if the Item property of the Display Form within third screen and the Edit Form within forth screen are both set to following formula:

BrowseGallery5.Selected

Note: The BrowseGallery5 represents the Gallery control within your second screen.

 

In addition, I agree with @dinusc's thought almost. I think there may be something wrong with the GroupBy function within the formula that you provided.

 

The GroupBy function returns a table with records grouped together based on the values in one or more columns. Records in the same group are placed into a single record, with a column added that holds a nested table of the remaining columns.

 

Please take a try to remove the GroupBy function from your formula that you provided and modify the Items property of BrowseGallery4 control as below:

SortByColumns(Search(WorkList,TextSearchBox4.Text,"CNumber"),"CNumber")

Then check if the issue is solved.

 

More details about the GroupBy function in PowerApps, please check the following article:

GroupBy function

 

 

Best regards,

Kris

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Husk457
Level: Powered On

Re: Edit form returns to correct record but returns to incorrect record when submitting form

I am not sure what to do here as far accepting the solution right now but happy to follow advice? I will return to the previous posts to acknowledge the assistance.

 

Removing the Groupby has eliminated the problem but given me other issues. The editform returns to the correct group of details with one exception. One of the feilds is used by the browse gallery as a sort. When that feild is changed it goes back to a different record within the group I presume it remebers an index number but sorted again before it is applied. Would be interested if that can be remedied but as it happens it works in well.

 

It has had massive remification to the app though.

 

MainBrowseScreen.PNG

 

On the screen I had the CNumber and a customer name each having many records but showing unique CNumbers allong with a customer name. I can only get the unique Cnumber with the following:

SortByColumns(Distinct(WorkList,CNumber),"Result")

I pass the result through to the next gallery:

SortByColumns(Search(Filter(WorkList,CNumber = BrowseGallery4.Selected.Result),Selection,"InternalExternal"),"Complete",Descending)

It all seems to work fine as far as the back end is concerned.

 

I have the follow problems (lack of knowledge):

  1. How do I get the CName (Customer Name) next to CNumber? I manage to concantenate which looked great but the could not pass the result through to the next browse screen. The CNumber to CName is a one to many relationship so one cusotomer can have many Cnumbers.
  2. My pie chart does not work anymore which is a measurement of count rows of "Not Started" and "Completed" going form Red to green as things are marked off as completed. I used the following formula which actually filled up with green but went back to Red when the all the record were marked as a completed? I would like to fix that as well?
    SortByColumns(
    AddColumns(
        GroupBy(Description,
            "Complete",
            "ByComplete"),
        "CountOfComplete",CountRows(ByComplete)),"Complete",Descending)
  3. The other figure was a count of rows that were marked "Not Started" using the following:
    CountRows(Filter(Description,Complete="Not Started"))
    I hope that I have not broken the rules here with this not sure if I should have started another topic? 

Answered my own problem but curious to know if there is a more more efficent way.

 

Main screen getting unique Cnumber and including CustomerName

 

SortByColumns(Distinct(WorkList,CNumber & " - " & CustomerName),"Result")

Used the following formula to strip back to the 6 digit Cnumber and link main screen to filter screen, added to the pie chart formula and totals number as well:

Left(BrowseGallery4.Selected.Result,6

I have a couple of other bugs but I think it should be a sepperate thread.

 

Thank you very much dinusc & Kris