cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Elitezone
Post Prodigy
Post Prodigy

How to view items (logical problem)

Hello,

 

I need some know-how, cause I have a huge problem in making my app logically correct.

 

I have a gallery with collection as data source. In this gallery I created inputboxes that you can input data in. Creating new gallery item - add new input fields that can be filled (commend collect).

When user finish adding all data he patch it to Sharepoint list.

 

This work on paper brilliantly, but the problem is that I want users to view this data from gallery anytime they want, and also modify it.

My app is for PC also so collection is dumped each log off.

 

I have no idea how to show this gallery with collection after app is reloaded. It is just empty.

My users can save data 24/7 and this patching to Sharepoint is just a step, cause at the end of the data each person has to click close session that patch once more and block adding new entries.

 

Is there a way to reload collection with data from Sharepoint list?

Or should I delete this gallery with collection and gallery with sharepoint list?

 

But how will I add new tasks to this gallery. In collection I use Collect and new item just appears...

 

7 REPLIES 7
Drrickryp
Super User
Super User

Hi @Elitezone 

IMHO, you should use the datasource as the Items property of a gallery unless there is a good reason to use a collection.  A collection exists in RAM memory but when the session ends it disappears. Moreover, if something happens before the user saves the data, they have to start it all over again.  This does not happen if you patch each item to the datasource as it is entered.     

Elitezone
Post Prodigy
Post Prodigy

@Drrickryp 

I use collection cause I can use gallery in a dynamic way.

 

Gallery with collection as a data source has one item by default and if I click collect it add a new entry. I can delete gallery dynamically too.

It is possible to do something like that with a sharepoint list as a data source?

@Elitezone 

Yes you can.  Powerapps works similar to Excel in that changes are reflected as soon as the data is entered successfully.  Galleries update automatically and calculations are executed once the data changes. 

Elitezone
Post Prodigy
Post Prodigy

@Drrickryp 

This is flawed. Because my gallery starts without record inputboxes will not be visible... I need at least one record to view them.

With Collection I used Collect in onVisible and first record was added. Like here. It won't... My gallery is always empty and I can't add records.

@Elitezone 

I see, you are using the gallery as a way to input data.  This is similar to how MS Infopath worked.  Shane Young (@Shanescows )has a three part series on exactly this topic.  https://www.youtube.com/watch?v=xgznk4XlPCo  I believe that you will find a good way to do what you want to.

 But first you told me to drop using collection and now you send me a link to a tutorial that uses collection to do this.

So confusing.

@Elitezone ,

@Drrickryp has given you some sound advice and can only respond to your requirements as you relate them in the particular comment. I will give you another idea here, but it is syntax/structure guidance and you will need to understand the concept to implement it.

Firstly, do this at App OnStart 

Set(varUserMail,User().Email)

Then create a new list in SharePoint with all the columns (same names and types) as the Collection as well as an additional one called UserMail - I have called the List StoreList below - you can call it whatever you want.

At App OnStart after the code above get the contents of the list that belong to the user

ClearCollect(
   CollectionName,
   Filter(
      StoreList,
      UserMail=varUserMail
   )
)

Now (this is actually the first bit to make it work) when you want to save this before the user exits - you will have to decide where to run this - update the contents of the user's collection, firstly by removing existing records and then adding the collection to it as new records.

RemoveIf(
   StoreList,
   UserMail=varUserMail
);
Collect(StoreList,CollectionName)

One small thing you will need to do is if the user adds a new record to the collection (you did not specify this), the field UserMail will need to be populated with varUserMail value.

 

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.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,796)