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

Adding fields to form in a collection

Hi All,

 

Newbe question. Are detail and edit forms really meant to be used with collections?

If I add a form to a screen I can select both an Excel sheet and a collection as the data source for it. With an Excel sheet as the data source I can then choose to add fields which are to be populated on the form.

 

But if I choose a collection it seems that it is not possible to add the fields. As a work around I first added the Excel sheet as the data source and then added the fields I needed. Then I changed the data source to the collection. The form still worked but now on the collection. The strange thing is that on the background of my form there is an image which says I need to make a connection to a data source.

 

So I got two questions:

  1. Are forms intended to be used with collections?
  2. How do I add fields from a collection to a form? Or is the workaround I choose the way it should be done.

 

3 REPLIES 3
Community Support Team
Community Support Team

Re: Adding fields to form in a collection

Hi @AGroegelich ,

Could you please share a bit more about your scenario?

Do you want to connect the Edit form to your collection data?

 

Actually, it is an known issue within PowerApps app -- Currently, the Edit form could only be connected to a Tabular data source, but the collection is actually a variable within canvas app.

 

Currently, if you want to connect a Edit form to a collection, and submit data to this collection, I afraid that there is no way to achieve your needs.

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

As an alternative solution, I think you could consider add a scrollable screen in your app, then add multiple data cards within the screen via clicking "Add section" button:

5.JPG

 

6.JPG

Within each Data card, add some Input controls (e.g. Text Input box). Then add a "Submit" button, set the OnSelect property to following:

Patch(     // Add new record
      ProductsCollection, 
      Defaults(ProductsCollection), 
     {
       ProductName: TextInput1.Text, 
       Price: Value(TextInput2.Text)
     }
)

use Patch function to submit data back to your collection rather than use SubmitForm function.

 

Best regards,

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.
AGroegelich
Level: Powered On

Re: Adding fields to form in a collection

Hi @v-xida-msft,

 

Do you want to connect the Edit form to your collection data?

Yes, that is what I want and also what I have got working. I got the idea because in the course I did they told me that in every place there was a Excel sheet as a datasource I could replace that by an collection.
The first app I build has a Excel sheet as the data source. When finished I copied that app and in that second app I replaced the Excel sheet by a collection as the data source. 

 

Also for the form I simply replaced the data source and I got it working. The behaved the same way as with the Excel sheet: fields can be modified, records can be added, etc using the Submit button. Of course this is now done to the collection so at the end I have to write back to the Excel sheet. There is a button for that the use can click.

However there are two issues that make me post this question:

  1. I cannot add fields any more as I can when the Excel sheet is the data source.
  2. The is a background image complaining I need to add a data source. It is not visible when running the app, so is don’t consider it a problem.
    12-2-2020 11-01-06.png

     

Currently, if you want to connect a Edit form to a collection, and submit data to this collection, I afraid that there is no way to achieve your needs.

It appears I proved otherwise, but… I had an issue with writing back the collection where the Filter part of a Patch statement was causing problems . It might be that I my misuse of the form is causing this problem, so it might not be a good idea, I am not sure. See: https://powerusers.microsoft.com/t5/Building-Power-Apps/Write-collection-to-Excel/m-p/464641/highlig...

 

I noted your alternative solution as something to try the next time I build an app. Looks good. Thanks you foor that suggestion.

AGroegelich
Level: Powered On

Re: Adding fields to form in a collection


If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

Done: https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Using-a-collection-as-a-data-source-in-a-displa...

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,103)