web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change data source for...
Power Apps
Answered

Change data source for an edit form based on gallery selected

(0) ShareShare
ReportReport
Posted on by 6

Hello All,

 

New to  Power Apps. Is there a recommended way to change the data source for an edit or display form depending on what gallery the record was selected from?

 

I have two tables from an excel sheet. TeamA and TeamB. Each team has entries that I want to modify/change the values of in an edit form. I want to use one edit form for both teams but the current issue is that I am only able to give it one data source. I could duplicate the edit form but I can see this becoming inefficient with more than 2 tables.

 

I currently have my edit form Item as 'teamAGallery.Selected' and the data source is tableA. Obviously this works for anything I do to team A but accessing through team B, writes into tableA. Is there a reccomended to deal with multiple data sources based on what 'team' I am accessing the entry from?

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at

    Hi @Aeko ,

    Set a Variable when OnSelect of the Galleries - Gallery A below

    Set(vGallNo,"A")

    On the DataSource of the form (use your table names).

    If(
     vGallNo = "A", 
     TableA, 
     TableB
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Verified answer
    v-siky-msft Profile Picture
    on at

    Hi @Aeko ,

    PowerApps Form control is not designed for multiple data source, it can only be bound to a single data source.

    If two tables' Column constructs are the same, we can show TableB Item in Form Table A(data source) Form, which means Form data source is Table A, but the Items property can be set as the record form TableB, then we have to use Patch function to save TableB records back to Table B, just think of the Form as a frame.

    Here is my test result:

    GIF_43.gif

    Steps:

    1.Set OnSelect of teamAGallery: Set(Var_SelectedItem,ThisItem);Set(Var_datasource,"TeamA")

    2.Set OnSelect of teamBGallery: Set(Var_SelectedItem,ThisItem);Set(Var_datasource,"TeamB")

    3.Set Form data source: TeamA or TeamB, anyone is ok

    4.Set Form Items property: Var_SelectedItem

    5.Set Save Button OnSelect: 

     

    If(
     Var_datasource="TeamA",Patch(TeamA,LookUp(TeamA,ID=Var_SelectedItem.ID),{ColumnName:DataCardValue1.Text});Refresh(TeamA),
     Var_datasource="TeamB",Patch(TeamB,LookUp(TeamB,ID=Var_SelectedItem.ID),{ColumnName:DataCardValue1.Text});Refresh(TeamB)
    )

     

    Hope this helps.

    Sik

     

     

  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at

    Hi @Aeko,

    and thanks @v-siky-msft  for confirming the principle.

    I have several forms and galleries bound conditionally to different data sources with identical fields (I think 6 is the most) and they work fine. Mostly galleries, but a number are edit forms, which also also work fine on SubmitForm.

     

     

  • Aeko Profile Picture
    6 on at

    Thanks for the reply. This was very useful, I was not aware of being able to set variables. 

     

    Thank you. I will let you know if this works for me once I try to implement it

     

  • WarrenBelz Profile Picture
    153,073 Most Valuable Professional on at

    Hi @Aeko ,

    Are you aware you selected your own post as the solution?

  • balakowsalya Profile Picture
    15 on at

    Hi @WarrenBelz / @v-siky-msft  ,

     

    I ran into the same issue that @Aeko  has mentioned but in my case, the data source is Sharepoint lists. I figured out the same solution to dynamically change the data source by storing the current data source to Set variables and update the data.

     

    It is working awesome for the Lists with the same fields, but I have an issue in editing the records for the lists with different fields. I'm not able to choose the data source for the edit/display form because it is taking only the Custom Datacards.

     

    I have different lists with different fields structure and want it to be sourced into the edit/display form for the update.

     

    It would really help me if you can guide me in solving this issue.

     

    Thanks in advance!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard