Dynamic Default Value from SharePoint List in Power Apps Toggle Control

PowerApp

Introduction

Power Apps, a low-code development platform by Microsoft, offers a variety of controls to create interactive applications. Among these is the Toggle control, which allows users to switch between two states - On and Off. In this article, we will explore the Toggle control in Power Apps and learn how to bind data from SharePoint, enhancing the functionality of your applications.

Benefits

  1. User-Friendly Interface: The Toggle control provides a simple and intuitive interface for users to toggle between two states, improving usability.
  2. Space Efficiency: Toggles occupy less space on the screen compared to other controls, making them ideal for mobile and tablet devices with limited screen real estate.
  3. Visual Feedback: The Toggle control provides visual feedback, indicating the current state (On or Off) to users, enhancing user experience.
  4. Data Binding: Binding data from SharePoint to the Toggle control allows for dynamic updating of states based on changes in SharePoint data, ensuring real-time synchronization.

Features

  1. Two-State Functionality: The Toggle control supports two states - On and Off, allowing users to easily switch between them.
  2. Customizable Appearance: Toggles can be customized in terms of color, size, and style to match the design requirements of the application.
  3. Event Handling: Power Apps allows developers to handle events associated with the Toggle control, such as OnChange events, to trigger actions based on user interactions.
  4. Accessibility: Toggles are accessible to users with disabilities and can be used in compliance with accessibility standards.

Limitations

  1. Limited States: Toggles support only two states - On and Off, making them unsuitable for scenarios requiring more than two options.
  2. Visual Clarity: In some cases, users may find it challenging to discern the current state of the Toggle control, especially if it lacks clear visual indicators.
  3. Complexity with Large Data: When binding large datasets from SharePoint, the Toggle control may experience performance issues or delays in data retrieval.

Step-by-Step Guide

  1. Open Power Apps
    • Click on the "Create" button.
      Home
    • Select "Blank app".
      Blank app
    • Choose "Blank tablet app" for tablet device compatibility.
      Blank tablet app
    • Provide a name for your app.
    • Select "Create" to proceed.
  2. Add SharePoint Data Source
    • Go to the "View" tab.
      Data
    • Click on "Data sources".
    • Select "Add data source".
      Data source
    • Choose "SharePoint" and provide connection details.
      Sharepoint
    • Select the SharePoint list from which you want to bind data.
  3. Insert Toggle Control
    • Navigate to the screen where you want to add the Toggle control.
      Back
    • Click on the "Insert" tab.
      Insert
    • Select "Input" and then choose "Toggle" from the dropdown menu.
    • Position the Toggle control on the screen.
  4. Bind Data from SharePoint

Bind Data

  • Select the Toggle control.
    • In the properties pane, locate the "Default" property.
    • Apply the formula
      Formula

Below is the function for the same.

First(DemoToggleList).ToggleYesNo

Replace "DemoToggleList" with the name of your SharePoint list and "ToggleYesNo" with the column containing the data you want to bind to the Toggle control.

  1. Beautify Your App
    Border
    Toggle control
    Lable
    Demo
    Demo toggle control
  2. Save and Publish
    Save and Publish
    Demo toggle list
    Demo toggle
    Edit data
  3. Save your changes
    Changes
  4. Publish the app to make it available for users.
    Publish the app

Conclusion

The Toggle control in Power Apps offers a simple yet powerful way to incorporate binary choices into your applications. By binding data from SharePoint, you can ensure that the Toggle control reflects the latest information from your SharePoint lists, enhancing the functionality and usability of your apps. While Toggles have their limitations, their benefits and features make them a valuable addition to any Power Apps project.


Similar Articles