Connecting to Sharepoint list in Canvas app

Loading

Detailed explanation of how to connect a SharePoint List to a Canvas App in Power Apps along with step-by-step instructions, best practices, and troubleshooting tips.


Step 1: Prerequisites

Before connecting to SharePoint in Power Apps, ensure you have:

  1. A SharePoint Online site.
  2. A SharePoint List with columns and data.
  3. Access permissions to read/write to the SharePoint List.
  4. A Power Apps environment with appropriate licenses.

Step 2: Create a New Canvas App

  1. Go to Power Apps.
  2. Click on “Create” → Choose “Canvas app from blank”.
  3. Give your app a name and choose Tablet or Phone layout.

Step 3: Connect to SharePoint List

  1. In Power Apps Studio, go to “Data” (left panel).
  2. Click “Add data”, then select “SharePoint”.
  3. If prompted, sign in with your Microsoft 365 credentials.
  4. Enter your SharePoint site URL and click Connect.
  5. Select the List you want to use and click Connect.

Step 4: Display SharePoint Data in a Gallery

  1. Insert a Gallery from the Insert tab.
  2. Set its Items property to: 'YourSharePointListName'
  3. Power Apps will auto-bind the list data to the gallery.
  4. Customize the gallery by selecting different layout styles.

Step 5: Display Detailed Information

  1. Insert a Form (Edit Form or Display Form).
  2. Set its DataSource to: 'YourSharePointListName'
  3. Set its Item property to: Gallery1.Selected
  4. Click Edit Fields to choose which columns to display.

Step 6: Add a Search Bar

To search records in the gallery:

  1. Insert a Text Input (txtSearch).
  2. Modify the Gallery’s Items property: Filter('YourSharePointListName', Title.Value & " " & Description.Value, txtSearch.Text)
  3. This will filter the list based on user input.

Step 7: Add a Form for Adding New Items

  1. Insert a Form (Edit Form).
  2. Set the DataSource to your SharePoint List.
  3. Add a Button with the following OnSelect code: SubmitForm(EditForm1)
  4. This will create a new entry in the SharePoint List.

Step 8: Edit an Existing Item

  1. Set the Form’s Item Property to: Gallery1.Selected
  2. Insert an Edit Button and set its OnSelect: EditForm(EditForm1)
  3. When the user clicks, the form will enter edit mode.

Step 9: Delete an Item

  1. Insert a Delete Button and set OnSelect to: Remove('YourSharePointListName', Gallery1.Selected)
  2. This will remove the selected item from SharePoint.

Step 10: Publish and Share the App

  1. Click File → Save & Publish.
  2. Click Share to give access to users.

Best Practices

  1. Use Delegation-Friendly Queries: Avoid Filter() on large datasets.
  2. Limit Data Calls: Use collections to store data offline.
  3. Use Patch for Performance: Instead of SubmitForm(), use: Patch('YourSharePointListName', Defaults('YourSharePointListName'), {Title: txtTitle.Text})
  4. Secure Access: Restrict permissions in SharePoint List settings.

Troubleshooting

IssueSolution
Data is not showing in the galleryCheck if the app is connected to the correct SharePoint list.
Delegation warningsUse StartsWith() instead of Filter(), or limit the number of records loaded.
App is slowLoad data into a collection (ClearCollect()) to improve performance.
Users can’t edit dataCheck if the user has Edit permissions in SharePoint.

This guide covers everything you need to connect, display, add, edit, and delete SharePoint List data in Power Apps. Let me know if you need any modifications or further explanations!

Leave a Reply

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