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 / Nested gallery questio...
Power Apps
Unanswered

Nested gallery question create new tecord

(0) ShareShare
ReportReport
Posted on by

Can anyone think how I can achieve this:

 

I have a vertical gallery with Office365Users filtered with ADDCOLUMNS called weekData comprising: (I had other columns originally so don’t really think ADDCOLUMNS is needed now):

 

CrewName.DisplayName = DisplayName

 

I then have a nested horizontal gallery with 7 columns for each day of the week and I set the VISIBLE property of a label in each day column based on some logic behind STARTDATE and ENDDATE. This works a treat and I can see the labels appear in each column based on a user’s start and end date. 

Can anyone think how I can set a “blank” box in each space on the week grid which can be clicked on to add a new record? I can’t get a blank box to appear unless there is some data already existing for a user’s line. I’ve tried having a button next to each user’s name in the primary gallery which then creates a new collection with DEFAULTS but this only adds a VALUE column rather than all columns? This then means I can’t patch new fields back to the collection?

 

Many thanks!

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jed76 

    You don't need to patch values back into a collection.  You only need a collection to provide a flexible table (add/remove/edit) for your gallery.

    So, there would need to be a lot more details on how your app is designed as far as getting the data into the gallery as well as how you are adding the new row.

  • jed76 Profile Picture
    on at

    @RandyHayes Thanks very much. The design is based on your kind help the other day with the primary vertical and then nested horizontal gallery. My issue is that obviously only something appears in the gallery if a record exists (ie if there is a record for a particular user with start and end dates, the horizontal gallery shows a label. What I need to do is have a label where there is no data which can be clicked on to create something?

     

    so it’s a grid with days across the week and each line is a user. I’d like a button in each square of the grid to click on to create an item for that particular box? Hope that makes more sense?

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jed76 

    Yes...I remember that interaction in the other posting!

     

    So again, the one key to this is having a collection (because you need to add and remove rows to a table - and a collection provides that).  When clicking the "add" in the gallery for the user, you would need to add (collect) a record in the collection with that user information (email preferably).  Then your nested gallery would be based on a Filter of the collection for the user.

     

    Does that make sense??

     

    One thing that is important is that collections do NOT contain primary keys.  Primary keys are essential for identifying records for updates and changes.  Because of this, since you are creating a new record, I like to add a primary key (made up as it is).  So the Collect statement would be more like:  Collect(yourCollection, {User: ThisItem.UserName, recID: GUID()})

    The recID then provides a unique identifier for any other operations that involve updating or removing that row.

     

     

  • jed76 Profile Picture
    on at

    Many thanks. I will keep trying based on your suggestions! I think the main thing that is confusing me is how to add a new row in the nested gallery if there is no data already there so I can’t get a button to appear of you see what I mean? How would the nested gallery ‘know’ what user name to allocate? 

  • jed76 Profile Picture
    on at

    Also, where you have the curly brackets above, do you not need PATCH before them? Also, I found today that when I was playing with patching the collection back to the data source, I got an INVALID message suggesting to me that the schema was incorrect?

  • jed76 Profile Picture
    on at

    72695285-947B-40E3-B6D1-8AF18DB81E89.jpeg

    This is what I have so far. The red boxes are based on the users start and end dates. This is a nested gallery based on the users down the right hand side. I’d like to be able to click on a blank box to add something new for that user’s particular line.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jed76 

    I wouldn't worry on the writing back part of your app just yet.  Get the mechanics of the app working first.

     

    No, curly brackets denote a record in PowerApps... in my example, I was collecting a record.

     

    Now, your Add button *should* be visible all the time.  You don't want the add button to be in the nested gallery, you want that to be in the main gallery.

     

    But, you are currently showing data in at least one user row.  How are you getting that data now?

    What are your Items properties for the main and nested gallery?

  • jed76 Profile Picture
    on at

    yes, I’ve tried the ADD button running down the vertical primary gallery but when I click on it for some reason the DEFAULTS doesn’t work in the collection? All I get is a VALUE column?

     

    The data in the nested gallery is coming from the primary galleries “weekData” as you described a few days ago. weekData is filtered from the main data source using (in my case); CrewName.DisplayName = DisplayName (CrewName is a PERSON column).

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @jed76 

    You don't need any of that.

    Your Add button should only be doing what I mentioned: Collect(yourCollection, {User: ThisItem.UserName, recID: GUID(), ID: Blank()})

    (NOTE: added a column for the Primary Key - ID)

     

    So, as for your data getting into this...you're going to need another approach to pulling the data into the gallery.  You will want to have it in your collection (which will become the filtered base of your nested gallery).

     

    Since it is a collection table, it will need to be maintained in the app (meaning, there will need to be actions to collect it and update as needed).

     

    This would all best be done in the Week change icons (the left and right icons).

     

    Let me know your Nested Gallery Items property and I can provide a formula to move over to those icons (or other places) to build your collection.

     

    This can be done without a collection, but it is a lot more work - trying to keep this simple for you.

     

    I am bagging out for the day here, so feel free to post back and I will pick up tomorrow on it.

  • jed76 Profile Picture
    on at

    @RandyHayes Many thanks!

     

    OK, so I have added that to the ADD BUTTON and I now get a collection. Upon looking at it, it seems that the USER column is populated with the user on the current line. For the ADD BUTTON I have used:

     

    Collect(colWWNew, User: ThisItem.DisplayName, recID: GUID(), ID: Blank()});

     

    My primary gallery item is:

     

    AddColumns(

    Office365Users.SearchUser(V2(

    {isSearchTermRequired: false}).value,

    "weekData",

     

    Filter(colTasks2 (THIS IS THE COLLECTION WHERE THE MAIN DATA GETS COLLECTED),

    CrewName.DisplayName=DisplayName))

     

    Then, the ITEM for the nested horizontal gallery is weekData.

     

    To add a new record, after the collection I navigate to a new page with a gallery with ITEMS "colWWNew". I have a label set to ThisItem.User which brings the current user selected through. I'd then like to choose a task and start and end dates which then patched back to "colTasks2" and subsequently back to the main SP List. 

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard