cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Damu_007
Frequent Visitor

How to Patch the Entire Child Gallery that is nested under Parent Gallery

I am working on an a Audit app to store audit results in to an SharePoint list. The audit questions have subcategories, So I have used Nested galleries (Gallery 1: Shows the audit category & Gallery 2 accommodates respective questions from the same category) and text boxes for user to provide input.

 

Requirement: I have to patch the category from Gallery 1 and questions from Gallery 2 along with the user inputs to a new SharePoint list

 

Problem: I pulled the category details in to the Gallery 2 using referencing labels(will be hidden in production) and patch the Gallery 2 to the SharePoint list which is not working.

Tried Solutions: -

Tried to patch individual Questions separately using a submit control : Working (This is the last option if Nothing else works) 

I was also trying different ways to patch the entire Gallery 2 in One Go. But couldn't succeed. Any workaround to achieve the same? Kindly let me know.

 

I tried this: Submitting the Child Gallery. None of the field's data got collected in patch

 

ForAll(

    SelhaGal3.AllItems,

    If(

        !IsBlank(SelhaScore.Text),

        Patch(

           'SELHA Audit Results',

            If(

                IsBlank(

                    LookUp(

                       'SELHA Audit Results',Title = Selha_Title_1.Text &&

                        'Process Step' = SelhaProcessStep.Text && Year = SelhaYear.Text

                    )

                ),

                Defaults('SELHA Audit Results'),

                LookUp(

                    'SELHA Audit Results',

                   Selha_Title_1.Text &&

                        'Process Step' = SelhaProcessStep.Text && Year = SelhaYear.Text

                )

            ),

            {

                'Question No': Value(QuestioNo.Text),

                 Title: Selha_Title_1.Text,

                Year: SelhaYear.Text,

                'Process Step': SelhaProcessStep.Text,

                'Process Classification': Selha_PC_1.Text,

                Weight: Value(Selhaweight.Text),

                Score: Value(SelhaScore.Text),

                Risk: SelhaRisk.Selected.Value, 

                Comments: SelhaComments.Text,

               'Audit Observations': SelhaAO.Text,

               'PCP Update': SelhaPCPUpdate.Text

            }

        )

    )

    );

6 REPLIES 6
RandyHayes
Super User
Super User

@Damu_007 

Can you expand a bit on what you are trying to accomplish?  Specifically, if you have multiple gallery 1 items and multiple gallery 2 items in each, what are you trying to update in your datasource?

Also, from your Record in your formula, what controls are where?  Which are part of Gallery1 and which are part of Gallery2?  

And finally, what are your Items properties for each Gallery?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi, This is an Audit App. as show in the Image I am using Gallery1 to show the category and gallery to show the subsequent questions under that category. The Source to this gallery is a list of Questions from a Sharepoint List. and I have provided text boxes to enter the inputs. 

Ideally I am trying to patch the Category from Gallery & each of its Questions from Gallery2 along with Users inputs to a new sharepoint list in one go (Becuase user wants to submit once after answering all the Questionnaire.  

I am using validation before updating or creating a new entry to the sharepoint list. Incase the combination exits already, then patch will update the item instead of creating a new one  

 

Regarding multiple items, Yes there are 12 categories (Gal 1 Items) & around 160 Questions divided in to 12 categories. So I tried to pass the Category to Gallery 2 using a label which will help me in submitting all the required data with the help one gallery itself 

 

(at the end the Gallery 1 is used only to show Category hierarchy) as I am trying patch the data that are from Gal 2. 

RandyHayes
Super User
Super User

@Damu_007 

Yes, I understand your scenario.  I was looking more for specific formulas for the Items property to help provide a more accurate solution for you.

 

So, the assumption is then that you have a GroupBy function as your Items property on the Gallery1 and that you are simply supplying the grouped items to Gallery2.  If you could provide those two Items properties, it would be helpful to this process.

 

I am not seeing what the names of your galleries are in your formula other than SelhaGal3.  Is that the Gallery1 or 2?

Can you supply the names of those Galleries in your app and which is referred to as Gallery1 - I see it in the picture, but don't know what its proper name is to reference in your formula.

 

I believe with that above information, I will have enough to provide you a working formula.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

I am using 3 different galleries,

 

I have not used Group By. I have filtered the info from data source in each of the Galleries depending on the previous gallery items

 

GALLERY: Isolated Gallery:  Only used to select different Main Categories (Process Type/Title))

 

Items : Distinct('SELHA Process Performance Questions', Process Type)

 

 

GALLERY_1 : I have filtered the Sub Categories (Process Classifications) that belongs to the chosen Process Type in GALLERY.

 

Items:

Distinct(Filter('SELHA Process Performance Questions',Process Type= GALLERY.Selected.Result),'Process Classification')

 

 

GALLERY_2 : This is an nested gallery inside GALLERY_1. I am filtering the Questions(Process steps) that are under the each Subcategory displayed in GALLERY_1.

 

Items: Filter('SELHA Process Performance Questions','Process Classification'= ThisItem.Result)

 

So in the formula I am trying to Submit only GALLERY_2. For that I am Passing the Title(Process Type) from GALLERY to GALLERY_2 (Label is hidden)

 

 

 

ForAll(
Gallery2.AllItems,
If(
!IsBlank(Gallery2Score.Text),
Patch(
'Sharepoint List',
If(
IsBlank(
LookUp(
'Sharepoint List', 'Process Type' = Gallery2_ProcessType.Text &&
'Process Step' = Gallery2ProcessStep.Text
)
),
Defaults(''Sharepoint List''),
LookUp(
'Sharepoint List', 'Process Type' = Gallery2_ProcessType.Text &&
'Process Step' = Gallery2ProcessStep.Text
)
),
{
'Question No': Value(QuestioNo.Text),
'Process Type': Gallery2_ProcessType.Text,
'Process Step': Gallery2ProcessStep.Text,
'Process Classification': Gallery2_ProcessClassification.Text,
Weight: Value(Gallery2weight.Text),
Score: Value(Gallery2Score.Text),
Risk: Gallery2Risk.Selected.Value,
Comments: Gallery2Comments.Text,
'Audit Observations': Gallery2AO.Text,
'PCP Update': Gallery2PCPUpdate.Text
}
)
)
);

 

RandyHayes
Super User
Super User

@Damu_007 

Ah...thanks for the details.  It helps a LOT!  Especially now seeing that there is a third gallery in the mix.

 

So, you're hitting your data source a lot for all these galleries to get the same data.

I would suggest the following:

For GALLERY, set the Items property to :

GroupBy('SELHA Process Performance Questions', "Process Type", "_classifications")

Then set the Items property of Gallery_1 to:

GroupBy(Gallery1.Selected._classifications, "Process Classification", "_questions")

And your nested Gallery_2 items to:

ThisItem._questions

The above formulas will reduce the performance hits of going to the datasource so many times and will reduce the maintenance of multiple filter formulas.

 

Next, you don't need any hidden labels to pass things as you already have everything you need in the Galleries.  You just need to reference the right things.  

There is one exception to the above statement - you will need one label to be hidden that will extract values from the nested gallery.  There is no purpose in that label.  It is only there due to a bug/issue with how PowerApps gets values from the nested gallery.  If you don't have it, it thinks the gallery is empty.  If you do, it will then see the galleries.  It's a whacky thing, but it resolves the issue.

 

Now...moving on to the end goal.

I am not seeing in your photo where you want to have this save button to save the information.  I am assuming that the button would be related to the current Process Type.  So, in other words, you would have a save button at the bottom or someplace that would save the question/answers for that particular Process Type selected in GALLERY.

Also not seeing in your picture where these hidden labels that you mention come into play.  If those hidden labels are referencing some columns of previous filter records, then these labels will have errors with the above changes - and the ultimate goal would be to remove all of them and have your gallery contain the data that it needs.

 

With that assumption, your formula for that save button would be the following:

 

Patch('SELHA Audit Results',
    Ungroup(
        ForAll(Filter(Gallery_1.AllItems, !IsBlank(selhaScore.Text)) As _class,
            {Answers: 
                ForAll(_class.Gallery_2.AllItems As _ans, 
                    {ID: LookUp('SELHA Audit Results', 'Process Type' = GALLERY.Selected.'Process Type' &&
                                'Process Step' = _class.'Process Step' && Year =_ans.Year, ID),
                     'Question No': _ans.'Question No',
                     Title: _ans.Title,
                     Year: _ans.Year,
                     'Process Step': _ans.'Process Step',
                     'Process Classification': _class.'Process Classification',
                     Weight: Value(_ans.Selhaweight.Text),
                     Score: Value(_ans.SelhaScore.Text),
                     Risk: _ans.SelhaRisk.Selected.Value, 
                     Comments: _ans.SelhaComments.Text,
                     'Audit Observations': _ans.SelhaAO.Text,
                     'PCP Update': _ans.SelhaPCPUpdate.Text    
                    }
                )
            }
        ),
        "Answers"
    )
)    

A lot of this formula is based on assumptions for things not seen in your picture or noted in your description, but the end result of the above is that it will create new records in the SharePoint list as needed, and update existing records as needed.

 

Oh...and I mentioned you need only one hidden label.  That is to resolve the issue with referencing nested galleries.

So, in your Gallery_1, add a label and set the Text property to: Concat(Gallery_2.AllItems, Title)

This just creates an outer reference to an inner gallery which will then let the above patch formula see the inner gallery items properly.  The label is not referenced anywhere, it just causes PowerApps to expose the nested gallery properly.

 

Give the above a shot and let me know if you run into issues or don't understand something.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Damu_007
Frequent Visitor

@RandyHayes I tried your formula, but still I am facing issues. Is there anyway we can connect separately, so that you can take look at the app and that might help to resolve this issue.

 

I tried the solution as it is (by renaming the controls), but faced the same issue. Also one thing I observed is with these formula I could see not all the elements were selected from the galleries that we are trying to patch.

 

I modified the query a little by providing the actual labels controls from the galleries. In this case all the elements were selected(Except Process Classification from Gallery 1) as you can see in the attached image. But it's still showing the error with patch command. I tried patching only elements from Gallery and Gallery 2, but nothing happened.

 

 

Helpful resources

Announcements

Take a short Community User Survey | Help us make your experience better!

To ensure that we are providing the best possible experience for Community members, we want to hear from you!    We value your feedback! As part of our commitment to enhancing your experience, we invite you to participate in a brief 15-question survey. Your insights will help us improve our services and better serve the community.   👉 Community User Survey    Thank you for being an essential part of our community!    Power Platform Engagement Team  

Tuesday Tip | How to Get Community Support

It's time for another Tuesday Tip, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.       This Week: All About Community Support Whether you're a seasoned community veteran or just getting started, you may need a bit of help from time to time! If you need to share feedback with the Community Engagement team about the community or are looking for ways we can assist you with user groups, events, or something else, Community Support is the place to start.   Community Support is part of every one of our communities, accessible to all our community members.   Within each community's Community Support page, you'll find three distinct areas, each with a different focus to help you when you need support from us most. Power Apps: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pa_community_support Power Automate: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpa_community_support Power Pages: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpp_community_support Copilot Studio: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pva_community-support   Community Support Form If you need more assistance, you can reach out to the Community Team via the Community support form. Choose the type of support you require and fill in the form accordingly. We will respond to you promptly.    Thank you for being an active part of our community. Your contributions make a difference!   Best Regards, The Community Management Team

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!     Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!     Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!     UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!     European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!   Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!   For more events, click the image below to visit the Microsoft Community Days website.    

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

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