cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SergiP
Advocate II
Advocate II

Selecting data source with a button

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

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

3 REPLIES 3
SergiP
Advocate II
Advocate II

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"

 

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.

chrila
Regular Visitor

Yes , but the function remove(BaseDades,BrowseGallery1.Selected ) doesn't work so far, have you a solution ?

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (3,485)