|
| 1 | +# SharePoint 'Follow/Discover Sites' |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +This is a proof of concept Power Apps solution designed to be embedded within a SharePoint site/page as a Web Part. It is designed as an alternative to the out of the box 'Sites' Web Part. |
| 6 | + |
| 7 | +It provides the user the ability to follow/unfollow a site from their currently followed sites (something which the out of the box 'Sites' Web Part does not do). |
| 8 | + |
| 9 | +In addition the user can discover new sites/search their followed sites by using the search box. |
| 10 | + |
| 11 | +The use of a low code/no code Power App means there is no need for custom development. |
| 12 | + |
| 13 | +The look and feel has been designed to replicate that of the out of the box Web Part. |
| 14 | + |
| 15 | +The Power App is fully responsive so can still render on a SharePoint page on a mobile device. The app supports both horizontal and vertical layouts. |
| 16 | + |
| 17 | +The solution is functionally complete but is provided as a POC for you to customise/extend as required. |
| 18 | + |
| 19 | +The SharePoint REST APIs are used to retrieve followed sites, search for sites and follow/unfollow them. |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +## Applies to |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +## Compatibility |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +## Contributors |
| 40 | + |
| 41 | +* [Alex Clark - Microsoft](https://github.com/alexc-MSFT) |
| 42 | + |
| 43 | +## Version history |
| 44 | + |
| 45 | +Version|Date|Comments |
| 46 | +-------|----|-------- |
| 47 | +1.0.0.0|Sep 14, 2023|Initial release |
| 48 | + |
| 49 | +## Prerequisites |
| 50 | + |
| 51 | +* Power Apps environment |
| 52 | +* Permissions to edit the page you wish to add the Power App to |
| 53 | +* SharePoint modern Team Site OR Communication Site |
| 54 | +* SharePoint site that ALL users who will use the app has **read** permissions to (this can be the same site where you will embed the app) |
| 55 | + |
| 56 | +## Solution Components |
| 57 | + |
| 58 | +The following solution components are used in this sample: |
| 59 | + |
| 60 | +* Follow Sites (Canvas App) |
| 61 | +* Get followed sites (Flow) |
| 62 | +* Follow Unfollow site (Flow) |
| 63 | +* Find sites (Flow) |
| 64 | + |
| 65 | +## Data Sources |
| 66 | + |
| 67 | +* SharePoint |
| 68 | + |
| 69 | +### Using the sample |
| 70 | + |
| 71 | +Follow the instructions below to deploy this sample to your tenant. Once deployed, the app (Follow Sites) is designed to be embedded within a SharePoint page. It can be embedded in a horizontal or vertical section. |
| 72 | + |
| 73 | +I would recommend using the 'Embed' Web Part and defining your own size. This works much better than the native Power Apps Web Part in terms of how it looks on the page. |
| 74 | + |
| 75 | +The recommended sizing is as follows: |
| 76 | + |
| 77 | +**Horizontal Layout** |
| 78 | + |
| 79 | +Width: 1024px |
| 80 | +Height: 170px |
| 81 | + |
| 82 | +**Vertical Layout** |
| 83 | + |
| 84 | +Width: 350px |
| 85 | +Height: 500px (reducing the height will display less sites, the user can scroll however) |
| 86 | + |
| 87 | +It is worth noting that the deployment instructions below assume a proficient level of knowledge of Power Apps, Power Automate and SharePoint Online. |
| 88 | + |
| 89 | +## Minimal Path to Awesome |
| 90 | + |
| 91 | +### Import Power Apps solution |
| 92 | + |
| 93 | +1. Download the **[Unmanaged](./solution/FollowSites_1_0_0_0.zip)** solution `.zip` from the **solution** folder. |
| 94 | + |
| 95 | +2. Within **<https://make.powerapps.com>**, import the `.zip` file via **Solutions** > **Import solution** > **Browse** and select the `.zip` file you just downloaded. |
| 96 | + |
| 97 | +3. Click next. |
| 98 | + |
| 99 | +4. When prompted connect the SharePoint data connection and select an appropriate SharePoint site that all users have READ access to (this is used for the REST API calls). |
| 100 | + |
| 101 | +5. Click Import. |
| 102 | + |
| 103 | +6. OPTIONAL - Update the color in the App OnStart event to match your SharePoint branding. Locate the below formula and update the hex codes. This will update the colors in the app. |
| 104 | + |
| 105 | +**colSiteColors**: Collection of Fluent colors that are used for the coloured part of the tiles, colors are selected at random. |
| 106 | + |
| 107 | +**gblFollowSitesColor**: Colors used in the search box. |
| 108 | + |
| 109 | +**gblTileBorderColor**: Border color for the site tiles. |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +` |
| 115 | +Set(gblMyToolsColor,"#0078d4"); |
| 116 | +` |
| 117 | + |
| 118 | +7. Add ALL users who will use the app as 'Run only users' for each Power Automate flow - 'Find sites', 'Get user followed sites', 'Follow Unfollow site'. This is required so they can be triggered by users from the app and will ensure the REST API calls are executed in the context of their accounts. You can use an AD group containing all users in your organization if you wish. |
| 119 | + |
| 120 | +8. Get the unique Id for the **Follow Sites** Power App from your tenant - Navigate to the Power Apps portal, select the app and click **Details** on the menu bar. Copy the **App ID** value. |
| 121 | + |
| 122 | +9. Embed the app in a SharePoint page. You can use the following embed code, replace the GUID after /apps/ with the Id you copied above. Feel free to change the size as you see fit (size below is for a horizontal layout). |
| 123 | + |
| 124 | +`<iframe width="1024px" height="170px" src="https://web.powerapps.com/webplayer/iframeapp?source=iframe&screenColor=rgba(104,101,171,1)&appId=/providers/Microsoft.PowerApps/apps/6cfd9913-5dac-48f8-b096-520fdf9ece6c"></iframe>` |
| 125 | + |
| 126 | +10. Republish your SharePoint page. |
| 127 | + |
| 128 | +11. Share the app with ALL users that have access to/will use your SharePoint site. |
| 129 | + |
| 130 | + |
| 131 | +## Using the Source Code |
| 132 | + |
| 133 | +You can also use the [Power Apps CLI](https://aka.ms/pac/docs) to pack the source code by following these steps:: |
| 134 | + |
| 135 | +* Clone the repository to a local drive. |
| 136 | +* Pack the source files back into `.zip` file: |
| 137 | + |
| 138 | + ```bash |
| 139 | + pac solution pack --folder pathtosourcefolder --zipfile pathtosolution --processCanvasApps |
| 140 | + ``` |
| 141 | + |
| 142 | + Making sure to replace `pathtosourcefolder` to point to the path to this sample's `sourcecode` folder, and `pathtosolution` to point to the path of this solution's `.zip` file (located under the `Solutions` folder). |
| 143 | +* Within **<https://make.powerapps.com>**, import the `.zip` file via **Solutions** > **Import solution** > **Browse** and select the `.zip` file you just downloaded. |
| 144 | +* Click next. |
| 145 | +* Click import. |
| 146 | +* Follow the steps above to configure and use the apps. |
| 147 | + |
| 148 | +## Features |
| 149 | + |
| 150 | +This sample app is a great way to learn some fundamental Power Apps and Power Automate concepts like: |
| 151 | + |
| 152 | +* Branding out-of-the-box controls |
| 153 | +* Working with SharePoint as a data source |
| 154 | +* Power Fx Formulas |
| 155 | +* Working with local collections |
| 156 | +* Building custom UIs |
| 157 | +* Responsive design |
| 158 | +* Using containers to build responsive layouts |
| 159 | +* Using the SharePoint REST APIs in Power Automate |
| 160 | + |
| 161 | +### How to use the app |
| 162 | + |
| 163 | +Using the app is designed to be fairly self explanatory for users. |
| 164 | + |
| 165 | +When the app first loads, the users' followed sites are retrieved by executing the 'Get user followed sites' flow. |
| 166 | + |
| 167 | +Sites can be followed/unfollowed using the 'star' icon in the tile (executes the 'Follow Unfollow Site' flow). |
| 168 | + |
| 169 | +Users can discover new sites/search their followed sites by using the search box. The search is performed when they tab out of the search box or click the search icon. |
| 170 | + |
| 171 | +Searches are performed using the SharePoint REST API through a Power Automate flow ('Find sites'). |
| 172 | + |
| 173 | +The search box must be cleared before the view is reset and the user can see their followed sites again. |
| 174 | + |
| 175 | +## Help |
| 176 | + |
| 177 | +We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues. |
| 178 | + |
| 179 | +If you encounter any issues while using this sample, you can [create a new issue](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=sharepoint-followsitess&authors=@alexc-MSFT&title=sharepoint-followsites%20-%20). |
| 180 | + |
| 181 | +For questions regarding this sample, [create a new question](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=sharepoint-followsites&authors=@alexc-MSFT&title=sharepoint-followsites%20-%20). |
| 182 | + |
| 183 | +Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=sharepoint-followsites&authors=@alexc-MSFT&title=sharepoint-followsites%20-%20). |
| 184 | + |
| 185 | +## For more information |
| 186 | + |
| 187 | +* [Overview of creating apps in Power Apps](https://docs.microsoft.com/powerapps/maker/) |
| 188 | +* [Power Apps canvas apps documentation](https://docs.microsoft.com/powerapps/maker/canvas-apps/) |
| 189 | + |
| 190 | +## Disclaimer |
| 191 | + |
| 192 | +**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** |
| 193 | + |
| 194 | +<img src="https://m365-visitor-stats.azurewebsites.net/powerplatform-samples/samples/sharepoint-followsites" /> |
0 commit comments