Skip to main content

Notifications

Community site session details

Community site session details

Session Id : WsVJkh7wK15C5b/0xLg3hi
Power Apps - Building Power Apps
Answered

Selecting data source with a button

Like (1) ShareShare
ReportReport
Posted on 6 Mar 2018 23:23:55 by 118

I have 2 data sources (Sharepoint Lists) List1 and List2 andI created an app that deals with these 2 lists.

These 2 lists have exactly the same columns.

In the first Screen of the app I have 2 buttons so that I can select List1 or List2 as data source for the rest of my screens. Basically the buttons are simply setting up a global variable with Set(BaseDades, List1)  or Set(Database, List2) with the 2nd button.

On the other screens and forms I use Database instead of List1 or List2 as source/Items...

Everything works great, so all forms take the records from the list I pick in the Wellcome screen and so far so good.

 

The only thing I can't figure out how to solve is the delete record icon on the DetailsScreen, the one that does: 

Remove(BaseDades, BrowseGallery1.Selected); If (IsEmpty(Errors(BaseDades, BrowseGallery1.Selected)), Back())

I get the error:  "The 1st argument of 'Remove' should be a collection".

 

I tried avoiding the use of BaseDades (the variable pointing to the chosen list) and using an if and pointing to list1 or 2, but it doesn't work either. In this case the error is:  "The collection does not accept items of this type"

 

How can I manage to delete the selected record, so that my Trashcan icon works?

 

thanks

Categories:
  • chrila Profile Picture
    2 on 05 Apr 2019 at 13:47:40
    Re: Selecting data source with a button
    Yes , but the function remove(BaseDades,BrowseGallery1.Selected ) doesn't work so far, have you a solution ?
  • Verified answer
    SergiP Profile Picture
    118 on 07 Mar 2018 at 07:17:57
    Re: Selecting data source with a button

    I found the problem. I forgot to change

    DetailForm1.DataSource= If(Tipus="C1", List1, List2)

    With this small change I can now select the List I'm going to work with though a button on the WellcomScreen.

    Awesome! I have 2 apps in 1.

  • SergiP Profile Picture
    118 on 07 Mar 2018 at 06:47:46
    Re: Selecting data source with a button

    I tried changing my approach and instead of using a global variable pointing to the DataSource, I used an if to point to the chosen DataSource:

    BrowseGallery1.Items = If(Tipus="C1", List1, List2)

    BrowseGallery1 shows perfectly the records from the chosen list, but then when I select one and go to the DetailScreen no data is displayed when I do:

    DetailForm1.Item= BrowseGallery1.Selected 

    I have the error:   "Invalid formula. Expected value compatible with Datasource"

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started
Loading complete