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

Edit form multiple data source

Hi,

 

I currently have an app with 2 screens and 2 sharepoint lists as my datasources. The lists are identical (but for our different departments).

 

On my first screen a drop down allows the user to change department - which changes the gallery to display the items from the chosen datasource. The user can then select the item, and move to the edit screen.

 

The edit screen - edit form will also change depending on which item the user selected on the home screen.

 

This all works well - however, the datasource for the edit forms will not change. I have tried a few different formulas but it errors or does not work.

 

This means when a user selects a department, selects an item, then moves to the edit screen, it retrieves all the correct information from the correct datasource (items are gallery1.selected), but the datasource for the edit form will not change to reflect the choice made on the initial dropdown, so an error occurs when trying to submit the form.

 

I have tried to change the datasource on the edit form to this:

 

If(Dropdown1.Selected.Value="X",Department1List,
Dropdown1.Selected.Value="Y",Department2List)

 

But that still errors.

 

Any help would be greatly appreciated!

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Edit form multiple data source

@AB4N 

I believe you are having difficulties changing the List because PowerApps Forms can only be bound to a single datasource.  The form cannot be conditionally bound to multiple datasources.  I will suggest 2 alternate design options to work around this in your app.

 

Option #1 

Combine the 2 Sharepoint lists into 1 list.  Add an extra column called Department and fill-in with the values Department1 or Department2. This can be determined using the Office 365 connector and looking at the employee's profile OR using the dropdown control.  To ensure employee's can only view/edit their own department's data enable Item level permissions in Sharepoint and restrict access.  Filtering of data should also take place within the app.

 

Option #2 

Bind the Edit form to a Collection instead of DepartmentList1 or DepartmentList2.  The collection should have all of the same fields as DepartmentList1&2.  Once the form is completed, instead of using the code Submit(EditFormName) in a button to Submit you'll need to PATCH the data instead using some code like Patch(myCollection,Defaults(myCollection),{field1:999, field2:"sometext"});

 

My personal preference would be for Option #1.  I think it would be easier to implement/maintain in the long run.  Of course, you should do whichever you feel most comfortable with and what works best your own situation.  Let me know if you have any general questions.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Edit form multiple data source

@AB4N 

I believe you are having difficulties changing the List because PowerApps Forms can only be bound to a single datasource.  The form cannot be conditionally bound to multiple datasources.  I will suggest 2 alternate design options to work around this in your app.

 

Option #1 

Combine the 2 Sharepoint lists into 1 list.  Add an extra column called Department and fill-in with the values Department1 or Department2. This can be determined using the Office 365 connector and looking at the employee's profile OR using the dropdown control.  To ensure employee's can only view/edit their own department's data enable Item level permissions in Sharepoint and restrict access.  Filtering of data should also take place within the app.

 

Option #2 

Bind the Edit form to a Collection instead of DepartmentList1 or DepartmentList2.  The collection should have all of the same fields as DepartmentList1&2.  Once the form is completed, instead of using the code Submit(EditFormName) in a button to Submit you'll need to PATCH the data instead using some code like Patch(myCollection,Defaults(myCollection),{field1:999, field2:"sometext"});

 

My personal preference would be for Option #1.  I think it would be easier to implement/maintain in the long run.  Of course, you should do whichever you feel most comfortable with and what works best your own situation.  Let me know if you have any general questions.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

AB4N
Level: Powered On

Re: Edit form multiple data source

Hi, that's great thank you! 

 

I chose your option of adding a department column and merging into one list. However, I am now finding it difficult to use a text input and drop down to filter these results, my previous method does not seem to work with this. 

 

I have managed to filter the results with this formula

If(Dropdown2.Selected.Value = "X", Filter(List, Department.Value = "X"),
Dropdown2.Selected.Value = "Y", Filter(List, Department.Value = "Y"), List)

 

But I am struggling to add a text input to this, to allow users to search from the items that have now been refined by the department dropdown.

 

Any suggestions?

 

Thank you for all your help!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,415)