web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Error Handling
Answered

From a sharepoint list to a gallery and viceversa

(0) ShareShare
ReportReport
Posted on by 94
I have a sharepoint list in a gallery. The gallery is in edit mode. I want to modify teh record in the gallery; for this i've put a button, in which i put this code: 
ForAll(
    Gallery2.AllItems As _Data;
    {
        ID: _Data.ID;
        Title: TextTitolo.Value;
        MODREDDITI2: ComboModredditi2.Selected.Value;
        LIQIVA: ComboLIQIVA.Selected.Value;
        IVALIPE: CheckLIPE.Checked;
        INTRASTAT: CheckINTRA.Checked;
        DICHIVA: CheckDICHIVA.Checked;
        IMU: CheckIMU.Checked;
        CU770: CheckCU770.Checked;
        TSANITARIA: CheckTSAN.Checked;
        ATTUALE: CheckATTUALE.Checked
    }
)
 
 
The gallery change value, but the new value is not reported in the sharepoint list. In the gallery, in the items, i've put the name of the sharepoint list.
This is the component of the screen:
 
 
I have the same question (0)
  • Suggested answer
    SebS Profile Picture
    4,567 Moderator on at
    From a sharepoint list to a gallery and viceversa
     
    The code inside ForAll is only creating a record in memory – it never writes to the data source.
    You must call Patch() (or UpdateIf) inside ForAll and target the SharePoint list.

    Something like this if You updating a record :

    ForAll(
        Gallery2.AllItems As row,
        Patch(
            MySharePointList,          // <-- your SharePoint list name
            LookUp(
                MySharePointList,
                ID = row.ID            // record to update
            ),
            {
                
                Title: TextTitolo.Text,
                MODREDDITIZZ: ComboModreddittiz2.Selected.Value,
                LIQIVA: ComboLIQIVA.Selected.Value,
                ILVALPE: CheckILPE.Value,
                INTRASTAT: CheckINTRA.Value,
                DICHIVA: CheckDICHIVA.Value,
                IMU: CheckIMU.Value,
                CU770: CheckCU770.Value,
                TSANITARIA: CheckTSAN.Value,
                ATTUALE: CheckATTUALE.Value
            }
        )
    );


    or if you crating a record

    ForAll(
        Gallery2.AllItems As row,
        Patch(
            MySharePointList,          // <-- your SharePoint list name
            Defaults(MySharePointList), // <-- your SharePoint list name
            {
                
                Title: TextTitolo.Text,
                MODREDDITIZZ: ComboModreddittiz2.Selected.Value,
                LIQIVA: ComboLIQIVA.Selected.Value,
                ILVALPE: CheckILPE.Value,
                INTRASTAT: CheckINTRA.Value,
                DICHIVA: CheckDICHIVA.Value,
                IMU: CheckIMU.Value,
                CU770: CheckCU770.Value,
                TSANITARIA: CheckTSAN.Value,
                ATTUALE: CheckATTUALE.Value
            }
        )
    );

    I hope that make sense but I'm not sure what Items you have in Your gallery as it will run after all of them and patch or crate records with Values from this controls so if you want update 1 record have Gallery2.Selected rather AllItems but I do not know context of solution you developing.
  • ancorte Profile Picture
    94 on at
    From a sharepoint list to a gallery and viceversa
    Thanks for your help. Now i modified the button, using also the collection. So the new button is :
    ForAll(
        Gallery2.AllItems;
        Patch(
            colClienti;
            LookUp(colClienti; ID = Gallery2ID.Value);
            {
                Title: TextTitolo.Value;
                MODREDDITI2: ComboModredditi2.Selected;
                LIQIVA: ComboLIQIVA.Selected;
                IVALIPE: CheckLIPE.Checked;
                INTRASTAT: CheckINTRA.Checked;
                DICHIVA: CheckDICHIVA.Checked;
                IMU: CheckIMU.Checked;
                CU770: CheckCU770.Checked;
                TSANITARIA: CheckTSAN.Checked;
                ATTUALE: CheckATTUALE.Checked
            }
        )
    )
     
    I've created the collection in the "Onvisible" of the screen. Anyway it doesn't function, it seems that i forget something to write the record that i modified in the list. IS it possibile because the button isn't in the same contenitor of the Gallery ?
     
  • Verified answer
    WarrenBelz Profile Picture
    152,667 Most Valuable Professional on at
    From a sharepoint list to a gallery and viceversa
    I will add a couple of items here for efficiency and clarity. Firstly ForAll is not designed to be a loop, although it can act that way if it contains an action inside it. ForAll creates a Table, which can be Patched in one action to the data source and will run much faster than individual Patches for each record. If it contains the ID of each record (as in your example), it will update the specific records, if not it will create new records.
    So your structure is fundamentally correct, however you are using the As disambigution operator in referring to the Gallery content (both data and controls), so you need to use the _Data alias against every control that is actually in the Gallery (omit for controls outside the Gallery).
    Patch(
       SPListName;
       ForAll(
          Gallery2.AllItems As _Data;
          {
             ID: _Data.ID;
             Title: Data.TextTitolo.Value;
             MODREDDITI2: _Data.ComboModredditi2.Selected.Value;
             LIQIVA: _Data.ComboLIQIVA.Selected.Value;
             IVALIPE: _Data.CheckLIPE.Checked;
             INTRASTAT: _Data.CheckINTRA.Checked;
             DICHIVA: _Data.CheckDICHIVA.Checked;
             IMU: _Data.CheckIMU.Checked;
             CU770: _Data.CheckCU770.Checked;
             TSANITARIA: _Data.CheckTSAN.Checked;
             ATTUALE: _Data.CheckATTUALE.Checked
          }
       )
    )
     
    Please ✅ Does this answer your question 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 answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
  • ancorte Profile Picture
    94 on at
    From a sharepoint list to a gallery and viceversa
    Thanks to all ! the last suggestion is ok !

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

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 724 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
SebS Profile Picture

SebS 239 Moderator

Last 30 days Overall leaderboard

Featured topics