cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
human-1562
Regular Visitor

SubmitForm in connection with Collections

Hello all,


I am using the SubmitForm in conjunction with a Local Collection, which in turn is an exact copy of a Sharepoint list.

2021-05-04 16_06_00-OE 5S - Büro App - Power Apps.png

 

If I am now in edit mode and change an input value and submit it with the SubmitForm, then Power Apps creates a new record for me, which means I have the old record and the new record.

 

2021-05-04 16_11_32-OE 5S - Büro App - Power Apps.png

2021-05-04 16_07_55-OE 5S - Büro App - Power Apps.png

This behavior is not wanted and also only exists for about 2 -4 weeks before that my developed solution worked great.

 

I do not know what to do, as an alternative I could use the patch function, but that is much more complex.

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@human-1562 

So, in PowerApps you cannot use different datasources with a Form successfully.  Even if they are the same schema.  Using a collection as a datasource for the form breaks the functionality of the form.

 

In general, to work around this, what you do is create a form for each datasource.  Then use the Visible property of the form to govern which one should be displayed.
As well for the Submit, you would determine which form to submit.

 

I am not sure if your Gallery is displaying data from the same datasource as the form, but it does not have to, you just need to apply logic there for getting the relevant record.   I only mention this so it is known. I don't know if even have this scenario (having records in your gallery from different datasources at the same time).

 

So, my suggestions are this...

In your OnStart of the app, apply some method to determine the team that the app will use.

Ex.  Set(glbTeam; "Test")  (purely example, this would be much more elaborate) 

 

Then, for your Gallery Items property - I would really evaluate the commonality of your different datasources.  If the schemas are Exact and will Never change, then you can get away with using a disparate filter such as:

Switch(glbTeam;
   "Test"; TestDatenListe;
   "Other"; OtherTeamData;
   ...etc...
)

The above is generally NOT advised, but if they are exact, it can be done.  If, again, there are chances that they change over time and are different in any way, then establishing a common schema in your app would be the preferred approach. 

 

So, for the source you mentioned in the original post, you would have your form (05EditForm) and set your DataSource to TestDatenListe and your Visible property of the form set to : glbTeam="Test"

 

Now in the Gallery OnSelect action or the Arrow OnSelect action depending on what you are using - 

Set(glbRecord; ThisItem);; 
EditForm(
    Switch(glbTeam;
        "Test"; 05EditForm;
        "Other"; OtherForm;
        ...etc...
    )
);;
Navigate(29Menue)

 

Set the Item property of your form to glbRecord

 

For your Submit OnSelect action:

    If(05EditForm.Unsaved; SubmitForm(05EditForm))

 

And in the OnSuccess action of 05EditForm:

Set(glbRecord; Self.LastSubmit);;
Set(AddNewList; false);;  
Set(ChangesWereMade; true);; 
Navigate(04PruefungBrowseScreen)

    

If you have some sort of "add new record" button or something, then you would want the formula on that to be:

NewForm(
    Switch(glbTeam;
        "Test"; 05EditForm;
        "Other"; OtherForm;
        ...etc...
    )
);;
Navigate(29Menue)

 

 

Hopefully that is relatively clear and helpful.

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

3 REPLIES 3
RandyHayes
Super User III
Super User III

@human-1562 

You have supplied information on the collection and the results, but nothing about your form.

What is the Item property of your Form?  And why a collection of the data duplicated?

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes 
here somthing about the from:

2021-05-04 18_12_41-Window.png

 

The '04BrowseGallery'.Selected is the gallery shown in my previous post.

Why do i use a separate list?

The extra list is filled by different sharepoint lists, depending on which team uses the app, so I don't have to develop a separate power app for each team.

 

All different sharepoint lists have the same structure (the table columns are the same), only the data and permissions are different



RandyHayes
Super User III
Super User III

@human-1562 

So, in PowerApps you cannot use different datasources with a Form successfully.  Even if they are the same schema.  Using a collection as a datasource for the form breaks the functionality of the form.

 

In general, to work around this, what you do is create a form for each datasource.  Then use the Visible property of the form to govern which one should be displayed.
As well for the Submit, you would determine which form to submit.

 

I am not sure if your Gallery is displaying data from the same datasource as the form, but it does not have to, you just need to apply logic there for getting the relevant record.   I only mention this so it is known. I don't know if even have this scenario (having records in your gallery from different datasources at the same time).

 

So, my suggestions are this...

In your OnStart of the app, apply some method to determine the team that the app will use.

Ex.  Set(glbTeam; "Test")  (purely example, this would be much more elaborate) 

 

Then, for your Gallery Items property - I would really evaluate the commonality of your different datasources.  If the schemas are Exact and will Never change, then you can get away with using a disparate filter such as:

Switch(glbTeam;
   "Test"; TestDatenListe;
   "Other"; OtherTeamData;
   ...etc...
)

The above is generally NOT advised, but if they are exact, it can be done.  If, again, there are chances that they change over time and are different in any way, then establishing a common schema in your app would be the preferred approach. 

 

So, for the source you mentioned in the original post, you would have your form (05EditForm) and set your DataSource to TestDatenListe and your Visible property of the form set to : glbTeam="Test"

 

Now in the Gallery OnSelect action or the Arrow OnSelect action depending on what you are using - 

Set(glbRecord; ThisItem);; 
EditForm(
    Switch(glbTeam;
        "Test"; 05EditForm;
        "Other"; OtherForm;
        ...etc...
    )
);;
Navigate(29Menue)

 

Set the Item property of your form to glbRecord

 

For your Submit OnSelect action:

    If(05EditForm.Unsaved; SubmitForm(05EditForm))

 

And in the OnSuccess action of 05EditForm:

Set(glbRecord; Self.LastSubmit);;
Set(AddNewList; false);;  
Set(ChangesWereMade; true);; 
Navigate(04PruefungBrowseScreen)

    

If you have some sort of "add new record" button or something, then you would want the formula on that to be:

NewForm(
    Switch(glbTeam;
        "Test"; 05EditForm;
        "Other"; OtherForm;
        ...etc...
    )
);;
Navigate(29Menue)

 

 

Hopefully that is relatively clear and helpful.

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

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,503)