cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Damu_007
Regular 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
Regular 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

Announcing | Super Users - 2023 Season 1

Super Users – 2023 Season 1    We are excited to kick off the Power Users Super User Program for 2023 - Season 1.  The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts.      Super User Season 1 | Contributions July 1, 2022 – December 31, 2022  Super User Season 2 | Contributions January 1, 2023 – June 30, 2023    Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile.    Power Apps  Power Automate  Power Virtual Agents  Power Pages  Pstork1*  Pstork1*  Pstork1*  OliverRodrigues  BCBuizer  Expiscornovus*  Expiscornovus*  ragavanrajan  AhmedSalih  grantjenkins  renatoromao    Mira_Ghaly*  Mira_Ghaly*      Sundeep_Malik*  Sundeep_Malik*      SudeepGhatakNZ*  SudeepGhatakNZ*      StretchFredrik*  StretchFredrik*      365-Assist*  365-Assist*      cha_cha  ekarim2020      timl  Hardesh15      iAm_ManCat  annajhaveri      SebS  Rhiassuring      LaurensM  abm      TheRobRush  Ankesh_49      WiZey  lbendlin      Nogueira1306  Kaif_Siddique      victorcp  RobElliott      dpoggemann  srduval      SBax  CFernandes      Roverandom  schwibach      Akser  CraigStewart      PowerRanger  MichaelAnnis      subsguts  David_MA      EricRegnier  edgonzales      zmansuri  GeorgiosG      ChrisPiasecki  ryule      AmDev  fchopo      phipps0218  tom_riha      theapurva  takolota     Akash17  momlo     BCLS776  Shuvam-rpa     rampprakash  ScottShearer     Rusk  ChristianAbata     cchannon  Koen5     a33ik        AaronKnox        Matren        Alex_10        Jeff_Thorpe        poweractivate        Ramole        DianaBirkelbach        DavidZoon        AJ_Z        PriyankaGeethik        BrianS        StalinPonnusamy        HamidBee        CNT        Anonymous_Hippo        Anchov        KeithAtherton        alaabitar        Tolu_Victor        KRider        sperry1625        IPC_ahaas      zuurg    rubin_boer   cwebb365      If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances.  Once they are received the list will be updated. 

Microsoft Power Platform Conference | Registration Open | Oct. 3-5 2023

We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida.   Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more.   Register today: https://www.powerplatformconf.com/   

Register now for the Business Applications Launch Event | Tuesday, April 4, 2023

Join us for an in-depth look into the latest updates across Microsoft Dynamics 365 and Microsoft Power Platform that are helping businesses overcome their biggest challenges today.   Find out about new features, capabilities, and best practices for connecting data to deliver exceptional customer experiences, collaborating, and creating using AI-powered capabilities, driving productivity with automation—and building towards future growth with today’s leading technology.   Microsoft leaders and experts will guide you through the full 2023 release wave 1 and how these advancements will help you: Expand visibility, reduce time, and enhance creativity in your departments and teams with unified, AI-powered capabilities.Empower your employees to focus on revenue-generating tasks while automating repetitive tasks.Connect people, data, and processes across your organization with modern collaboration tools.Innovate without limits using the latest in low-code development, including new GPT-powered capabilities.    Click Here to Register Today!    

Check out the new Power Platform Communities Front Door Experience!

We are excited to share the ‘Power Platform Communities Front Door’ experience with you!   Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well.       Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities.     Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform.    Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.

Welcome to the Power Apps Community

Welcome! Congratulations on joining the Microsoft Power Apps community! You are now a part of a vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun! Now that you are a member, you can enjoy the following resources:   The Microsoft Power Apps Community Forums If you are looking for support with any part of Microsoft Power Apps, our forums are the place to go. They are titled "Get Help with Microsoft Power Apps " and there you will find thousands of technical professionals with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Apps community forums! Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered!   Microsoft Power Apps IdeasDo you have an idea to improve the Microsoft Power Apps experience, or a feature request for future product updates? Then the "Power Apps Ideas" section is where you can contribute your suggestions and vote for ideas posted by other community members. We constantly look to the most voted Ideas when planning updates, so your suggestions and votes will always make a difference.   Community Blog & NewsOver the years, more than 600 Power Apps Community Blog Articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on building Power Apps. On the Power Apps Community Blog, read the latest Power Apps related posts from our community blog authors around the world. Let us know if you would like to become an author and contribute your own writing — everything Power Apps related is welcome!   Power Apps Samples, Learning and Videos GalleriesOur galleries have a little bit of everything to do with Power Apps. Our galleries are great for finding inspiration for your next app or component. You can view, comment and kudo the apps and component gallery to see what others have created! Or share Power Apps that you have created with other Power Apps enthusiasts. Along with all of that awesome content, there is the Power Apps Community Video & MBAS gallery where you can watch tutorials and demos by Microsoft staff, partners, and community gurus in our community video gallery.   Again, we are excited to welcome you to the Microsoft Power Apps community family! Whether you are brand new to the world of process automation or you are a seasoned Power Apps veteran. Our goal is to shape the community to be your ‘go to’ for support, networking, education, inspiration and encouragement as we enjoy this adventure together!   Let us know in the Community Feedback if you have any questions or comments about your community experience.To learn more about the community and your account be sure to visit our Community Support Area boards to learn more! We look forward to seeing you in the Power Apps Community!The Power Apps Team

Microsoft Power Platform | March 2023 Newsletter

Welcome to our March 2023 Newsletter, where we'll be highlighting the great work of our members within our Biz Apps communities, alongside the latest news, video releases, and upcoming events. If you're new to the community, be sure to subscribe to the News & Announcements and stay up to date with the latest news from our ever-growing membership network who find real "Power in the Community".    LATEST NEWS Power Platform Connections Check out Episode Five of Power Platform Connections, as David Warner II and Hugo Bernier chat with #PowerAutomate Vice President, Stephen Siciliano, alongside reviewing out the great work of Vesa Juvonen, Waldek Mastykarz, Maximilian Müller, Kristine Kolodziejski, Danish Naglekar, Cat Schneider, Victor Dantas, and many more.   Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show!   Did you miss an episode?  Catch up now in the Community Connections Galleries Power Apps, Power Automate, Power Virtual Agents, Power Pages     Power Platform leading a new era of AI-generated low-code development.   **HOT OFF THE PRESS** Fantastic piece here by Charles Lamanna on how we're reinventing software development with Copilot in Power Platform to help you can build apps, flows, and bots with just a simple description! Click here to see the Product Blog         Copilot for Power Apps - Power CAT Live To follow on from Charles' blog, check out #PowerCATLive as Phil Topness gives Clay Wesener Wesner a tour of the capabilities of Copilot in Power Apps.       UPCOMING EVENTS   Modern Workplace Conference Check out the Power Platform and Microsoft 365 Modern Workplace Conference that returns face-to-face at the Espace St Martin in Paris on 27-28th March. The #MWCP23 will feature a wide range of expert speakers, including Nadia Yahiaoui, Amanda Sterner, Pierre-Henri, Chirag Patel, Chris Hoard, Edyta Gorzoń, Erika Beaumier, Estelle Auberix, Femke Cornelissen, Frank POIREAU, Gaëlle Moreau, Gilles Pommier, Ilya Fainberg, Julie Ecolivet, Mai-Lynn Lien, Marijn Somers, Merethe Stave, Nikki Chapple, Patrick Guimonet, Penda Sow, Pieter Op De Beéck, Rémi Riche, Robin Doudoux, Stéphanie Delcroix, Yves Habersaat and many more.  Click here to find out more and register today!     Business Applications Launch 2023 Join us on Tuesday 4th April 2023 for an in-depth look into the latest updates across Microsoft Power Platform and Microsoft Dynamics 365 that are helping businesses overcome their biggest challenges today. Find out about new features, capabilities, and best practices for connecting data to deliver exceptional customer experiences, collaborating and creating using AI-powered capabilities, driving productivity with automation, and building future growth with today’s leading technology. Click Here to Register Today!       Power Platform Conference 2023 We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5th, 2023! But first, let's take a look below at some fun moments from MPPC 2022 in Orlando Florida. 2023 sees guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, and many more taking part, so why not click the link below to register for the #PowerPlatformConf today! Vegas, baby! Click Here to Register Today!      COMMUNITY HIGHLIGHTS Check out our top Super and Community Users reaching new levels!  These hardworking members are posting, answering questions, kudos, and providing top solutions in their communities.   Power Apps:  Super Users:  @WarrenBelz  |  @iAm_ManCat  Community Users: @LaurensM | @Rusk | @RJM07    Power Automate:   Super Users: @abm  | @Expiscornovus | @RobElliott  Community Users:  @grantjenkins | @Chriddle    Power Virtual Agents:   Super Users: @Expiscornovus | @Pstork1  Community Users: @MisterBates | @Jupyter123 | Kunal K   Power Pages: Super Users:  @OliverRodriguesOliverRodrigues | @Mira_Ghaly  Community Users: @FubarFubar | @ianwukianwuk  LATEST PRODUCT BLOG ARTICLES  Power Apps Community Blog  Power Automate Community Blog  Power Virtual Agents Community Blog  Power Pages Community Blog  Check out 'Using the Community' for more helpful tips and information:  Power Apps, Power Automate, Power Virtual Agents, Power Pages 

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