Giter Club home page Giter Club logo

enhanced-power-apps-embed's Introduction

Enhanced Power Apps Embed Webpart icon Enhanced Power Apps Embed Webpart

Table of Contents

Summary

This SPFx (SharePoint Framework) webpart improves on the existing react-enhanced-powerapps solution developed by Hugo Bernier (GitHub) so I highly recommend you check out his work and see what the orginal version already could do. When using his webpart myself, I thought to myself "passing a SharePoint context parameter to your embedded Power App is great, but why should it be limited to only one?". That is why this enhanced webpart allows you to embed a Power App in SharePoint and use various page context parameters within your app by calling the Param("{contextParamName}") function, as well as configuring your own dynamic parameter in the property panel. See how to implement for a detailed description of how it works.

Download .sppkg file Download the .sppkg file here!

Used SharePoint Framework Version

version

Applies to

Prerequisites

  • Node.js v10/12/14
  • (optional) An M365 account. Get your own free Microsoft 365 tenant from M365 developer program

Solution

Solution Author(s)
Enhanced Power Apps Embed Webpart cup o'365 (Contact, Website)

Version history

Version Date Comments
1.0 April 3, 2022 Initial release

Supported languages

  • English
  • Dutch

How to implement

By default, the webpart provides various SharePoint context variables by passing them to the Power App via the HTML iframe element URL as parameters. These parameters are (by default) as follows:

Name Type Description Example
tenantId guid Unique identifier of the tenant "f494b1c5-bb1c-46fc-9c9b-b3d6bbf41e43"
languageId number LCID value of the configured language on the page the app is embedded on (see also) 1033
languageName text The language tag name of the configured language on the page the app is embedded on (see also) "en-US"
siteTitle text The name of site on which the app is embedded on "Dev team"
portalUrl text The SharePoint base URL of the page on which the app is embedded on "https://cupo365.sharepoint.com/"
absoluteUrl text The site URL of the page which the app is embedded on "https://cupo365.sharepoint.com/sites/DevTeam"
serverRelativeUrl text The relative path from the SharePoint base URL of the page on which the app is embedded on "/sites/DevTeam"
serverRequestPath text The relative path from the server relative URL of the page on whic the app is embedded on "/SitePages/Enhanced Power Apps Embed test.aspx"
groupId guid Unique identifier of the Office-group intertwined with the SharePoint site on which the app is embedded on "d0496f03-563d-4f50-8b29-f84560ddfdd1"
groupType text Whether the group intertwined with the SharePoint site on which the app is embedded on is public or private "Public"
isTeamsConnectedSite booolean Whether the site of the page the app is embedded on is a Teams site false
isTeamsChannelSite boolean Whether the site of the page the app is embedded on is a Teams channel false
isArchived boolean Whether the site on which the app is embedded on is archived false
isHubSite boolean Whether the site on which the app is embedded on is a hub site false
userId guid Unique identifier of the user "d581c3b1-011f-4cef-bf15-cf4074eca852"
displayName text The Office display name of the user "Lennart de Waart"
email text The email address of the user "[email protected]"
isAnonymousGuestUser boolean Whether the user is an anonymous guest false
isExternalGuestUser boolean Whether the user is an external guest false
isSiteAdmin boolean Whether the user is the admin of the site on which the app is embedded on false
isSiteOwner boolean Whether the user is the owner of the site on which the app is embedded on false

You can fetch these context parameters in your Power App by calling the Params("{contextParameterName}") function. You can fetch and use them individually, or use this formula in your app's OnStart to create a global variable of a compiled record of all of these context parameters which you can call later on:

Set(
    varEmbeddedContext,
    {
        aadInfo: {tenantId: Param("tenantId")},
        cultureInfo: {
            languageId: Param("languageId"),
            languageName: Param("languageName")
        },
        site: {
            title: Param("siteTitle"),
            portalUrl: Param("portalUrl"),
            absoluteUrl: Param("absoluteUrl"),
            serverRelativeUrl: Param("serverRelativeUrl"),
            serverRequestPath: Param("serverRequestPath"),
            group: {
                id: Param("groupId"),
                type: Param("groupType")
            },
            isTeamsConnectedSite: Param("isTeamsConnectedSite"),
            isTeamsChannelSite: Param("isTeamsChannelSite"),
            isArchived: Param("isArchived"),
            isHubSite: Param("isHubSite")
        },
        user: {
            id: Param("userId"),
            displayName: Param("displayName"),
            email: Param("email"),
            isAnonymousGuestUser: Param("isAnonymousGuestUser"),
            isExternalGuestUser: Param("isExternalGuestUser"),
            isSiteAdmin: Param("isSiteAdmin"),
            isSiteOwner: Param("isSiteOwner")
        }
    }
);

Furthermore, you can configure your own (dynamic) context parameter in the property pane of the webpart, just like the version of Hugo Bernier.

Download .sppkg file Download the .sppkg file here!

enhanced-power-apps-embed's People

Contributors

cupo365 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

enhanced-power-apps-embed's Issues

WebPart doesn't load in Teams on iPad/iPhone

I created a SharePoint Page with the Enhanced Power Apps WebPart. This page is integrated as a Tab in an MS Teams Team.
When I open this teams tab on an iPad or iPhone, the webpart and the power app are not rendered. The page is blank.

The webpart including the Power App is rendering properly under the following conditions:

  • Open in any Browser under Windows
  • linked as a Tab in MS Teams App under Windows (only Teams in browser)
  • open in Chrome on Mac OS
  • open in Safari on Mac OS
  • open in Chrome on iPad (iOS 15.5)
  • open in Safari on iPad (iOS 15.5)

This issue also exists when you integrate the SharePoint site as Home Site with Microsoft Viva and try to access the page via Teams. The issue occurs on Teams app on Windows, Teams app on iPhone or iPad.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.