938 Views
5 minutes read
Categories
Office 365 Power Apps

[Solved] How to create Repeating Section in PowerApps and save data to SharePoint List

PowerApps is surely gaining traction among business users due its low code no code approach and easy integration with a variety of data stores and apps. However, there are occasions when certain controls are not readily available and one needs to apply few tweaks to achieve the desired result. We faced one such situation in our project and I wish to discuss that in this article. 

In one of our recent projects we needed to  migrate some Nintex forms integrated with SharePoint list to Power Platform. These Nintex forms had some repeating sections. 

What is Repeating Section? 

Repeating Section in Nintex is a control which can contain a set of other controls and allows a user of the form to insert multiple instances (rows) of data as required. A typical use is to capture personal details such as multiple phone numbers of a person as shown below. The type of phone and its number are small controls that are repeating to capture multiple sets of data. The trouble is  the child controls are connected to the Repeating Section control and thus cannot be directly connected to SharePoint list columns or fields. 

How to create Repeating Section in PowerApps and save data to SharePoint List

Also, in PowerApps we do not have any default control like repeating section in Nintex form.  

How to create repeating sections in PowerApps? 

You have guessed it! We need to mix few things in PowerApps to get to the point. I created the repeating section in PowerApps using form, gallery, and button controls. 

Follow through the steps below to create a. Repeating Section in PowerApps and also saving data from this section to the SharePoint list. 

Steps:

  1. Create a list column of type multiple lines of text in your SharePoint list to store the data from repeating section. Just like here I have a column named ‘Repeating Section Data’.
How to create Repeating Section in PowerApps and save data to SharePoint List

2. In PowerApps screen, add the edit form which will be connected to your SharePoint list and hide the column ‘Repeating Section Data’.

How to create Repeating Section in PowerApps and save data to SharePoint List

3. The repeating section cannot be created inside your form. You must create the section outside the form.

4. Add a gallery with the controls you need to save data for the repeating section and a ‘x’ (cancel) button. Also, below the gallery add a ‘+’ icon to add rows and a save icon to save data in all the rows. This should look something like this:

How to create Repeating Section in PowerApps and save data to SharePoint List

5. In the ‘OnSelect’ property of the ‘+’ icon add these lines of code.

Collect (CollRepSec,
    {
        SrNo: Text (2 + (CountRows (CollRepSec) + 1) / 10),
        Type: "",
        Description: ""
    }
);
How to create Repeating Section in PowerApps and save data to SharePoint List

6. In the gallery’s Items property, add collection “ColRepSec”.

How to create Repeating Section in PowerApps and save data to SharePoint List

7. Edit the Fields property of the gallery and add the respective fields to each of the controls.

How to create Repeating Section in PowerApps and save data to SharePoint List

8. Now, add the following code in the cancel button of the gallery.

RemoveIf (CollRepSec, SrNo = ThisItem.SrNo);

9. In the ‘OnSelect’ property of the save icon add the following lines of code:

UpdateContext (  
    {  
        RepSecCOllString: Concat (  
            GalleryRepSec.AllItems,  
            Concatenate (
                 LabelSrNo.Text,
                 ";",
                DropdownType.Selected.Value,  
                ";",  
                TextInputDesc.Text,    
                “;”,
                "|"  
            )  
        )  
    }  
);

10. Now add the variable ‘RepSecCollString” to the Update property of your ‘Repeating Section Data’ data card in the form.       

How to create Repeating Section in PowerApps and save data to SharePoint List

11. Make sure to clear the collection ‘ColRepSec’ by adding the following code in the OnNew property of the SharePointIntegration in your form.

Clear (CollRepSec);

There you are. Now when you add rows in the repeating section the form will look like this.

How to create Repeating Section in PowerApps and save data to SharePoint List

And when you save it the data is being saved in the list like this.

How to create Repeating Section in PowerApps and save data to SharePoint List

As I said, many people are moving to PowerApps from their existing system. The existing forms could be InfoPath, Nintex like in our case or even some custom applications. The source really doesn’t matter as long as you are able to mimic the control within PowerApps and also save the data into native SharePoint data store.

Hope you will be able to use the artefact described here for your purposes and I would feel happy if you do. Let me know for more assistance.

It may also be needed to later retrieve the data and be able to edit it. That’s exactly my plan to discuss it in the next article!

Baishakhi Adhikary

About Baishakhi Adhikary

Baishakhi is currently working as an Associate Software Engineer with a demonstrated history of working in the information technology and services industry. She has extensive knowledge in Python, C#, Microsoft SharePoint, and Microsoft PowerApps.

LinkedinTwitterFacebook

Leave a Reply

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