Showing Repeating Section Data from SharePoint List in Power Apps - Netwoven
Blog

Showing Repeating Section Data from SharePoint List in Power Apps

By Baishakhi Adhikary  |  Published on May 3, 2021

Showing Repeating Section Data from SharePoint List in Power Apps

This is just a small addendum to my previous article . Once you have created a repeating section in PowerApps and saved it in a SharePoint list, I am going to show you one easy step to retrieve those data from the SharePoint list and make them available in edit and view form.

I am sure you already have created the repeating section in your form. If you haven’t yet, please refer to my earlier blog.

Now consider the following lines of code in the OnEdit and OnView property of SharePointIntegration of the form.

Set (RepSecCOllString, LookUp( 'Repeating Section Test', ID=SharePointIntegration.SelectedListItemID, 'Repeating Section Data')); Clear (CollRepSec);
Set (EditRepSecStr,LookUp( 'Repeating Section Test', ID=SharePointIntegration.SelectedListItemID , 'Repeating Section Data'));Set(EditRepSecStr,Left(EditRepSecStr,Len(EditRepSecStr) - 1));
ForAll (  
    Split (  
        EditRepSecStr,  
        "|"  
    ),  
    Collect (  
        CollRepSec,  
        {  
            SrNo: Text (Last (FirstN(Split(Result,";").Result,1).Result).Result),
            Type: Text (Last (FirstN(Split(Result,";").Result,2).Result).Result),
            Description: Text (Last (FirstN(Split(Result,";").Result,3).Result).Result) 
        }  
    )  
)
Showing Repeating Section Data from SharePoint List in Power Apps

Finally, when you open your SharePoint form in edit and view mode you will be able to see your data like this.

Showing Repeating Section Data from SharePoint List in Power Apps

This concludes the demonstration of how easily you can make use of repeating sections perhaps even to create an editable grid. PowerApps do not yet provide a straight forward grid control and this is one of the ways to get to a workaround. I thought tables are pretty important controls to use!

Let me know what you think of it.

14 comments

  1. I added this in a button to load the gallery with some data, it addes three gallery items with null values in the text box

    Set(ProjectAmountDescriptionsgal,”245;adding 245;| 265;adding 265;|”);

    ForAll(
    Split(
    ProjectAmountDescriptionsgal,
    “|”
    ),
    Collect(
    Spendingcoll,
    {
    ColAmount: Text(
    Last(
    FirstN(
    Split(
    Result,
    “;”
    ).Result,
    1
    ).Result
    ).Result
    ),
    ColAmountDesc: Text(
    Last(
    FirstN(
    Split(
    Result,
    “;”
    ).Result,
    1
    ).Result
    ).Result
    )
    }
    )
    );

  2. Set (RepSecCOllString, LookUp( ‘Repeating Section Test’, ID=SharePointIntegration.SelectedListItemID, ‘Repeating Section Data’)); Clear (CollRepSec);
    In the above code, what is mean ‘Repeating Section Test’. Is it List name? or Repeating section column name in the list? Please can you help me to understand this line.

  3. I have text box, people picker (combobox), dropdown controls in the gallery (repeating table) and followed your steps. working for text box and multiline text but not for people picker.
    How to assign email address to people picker control in Power apps gallery? As you mentioned, I able to split text but not working for people picker like below code
    AssingedTo:Text (Last (FirstN(Split(Result,”;”).Result,5).Result).Result)
    Please can you help on this?

  4. Hi,
    Hope you are doing well.
    I achieved everything as above. Thanks for the help.
    However, when i edit an already created form and delete the rows and save, new list item is created. how to overcome this.

  5. I am trying to use this in a Power App with a SharePoint list as my data source. How or where would I add this code to my form that uses the SP list as the datasource? I am not seeing any OnEdit or OnView properties there.

  6. I do not get the items stacked , I get a scroll bar. but when I add this new code. in the OnEdit and Onview. however, it writes a new record to the SharePoint list. instead of updating the current record.
    when I go to edit an existing record it is blank, none of the original entries are there and it creates a new line item.
    I was wondering do these items have to make the type of input box they are like Dropdowns?

  7. Hi Baishakhi,
    thank you very much for your great post. I followed your instructions, all of my collection columns in my gallery are saved in a sharepoint list column (multiline textbox).
    But I’m currently struggeling with a comboBox for PeoplePicker (mulitvalue). There I have to set the “Default Selected Items” Property. My “Item”Property is set to: Filter(Office365Users.SearchUser(
    {searchTerm:input_ComboBox_BesIntern.SearchText,top:999}), AccountEnabled=true)
    But how must the Default Selected Item Property be configured?
    Thank you very much in advance for your help !
    Gerlind

    1. To set the “Default Selected Items” property for the ComboBox control used as a PeoplePicker (multi-value), you can follow these steps:
      Step 1: Create a Collection “DefaultUsers” by searching for users and store it in the variable.
      ClearCollect(
      DefaultUsers,
      Office365Users.SearchUser({searchTerm: User().Email}),
      Office365Users.SearchUser({searchTerm: “user1@domain.com”}),
      Office365Users.SearchUser({searchTerm: “user2@domain.com”})
      )
      In this example, the collection “DefaultUsers” will be created by searching for the current user’s email (User().Email) and two specific email addresses “user1@domain.com” and “user2@domain.com”. You have to adjust the formulas based on your specific data source and filtering criteria.

      Step 2: Set the variable “DefaultUsers” under default selected items in the ComboBox control.
      ComboBoxName.DefaultSelectedItems = DefaultUsers
      Replace “ComboBoxName” with the actual name of your ComboBox control.

      By following these steps, the ComboBox control will have the users from the “DefaultUsers” collection as the default selected items.

Leave a comment

Your email address will not be published. Required fields are marked *

Unravel The Complex
Stay Connected

Subscribe and receive the latest insights

Netwoven Inc. - Microsoft Solutions Partner

Get involved by tagging Netwoven experiences using our official hashtag #UnravelTheComplex