SharePoint Embedded Container Types with Graph API and Power Automate
1. What are SharePoint Embedded Container Types?
SharePoint Embedded Container Types refer to various modular components that can be embedded or housed within SharePoint, allowing for a customizable and integrated experience. These can include:
Web Parts: Small modules that can be added to SharePoint pages to display content or provide functionality (e.g., a document library, news feed, or calendar).
PowerApps: Custom apps embedded directly into SharePoint lists, libraries, or pages to extend functionality.
Forms: Embedding Microsoft Forms or custom forms into SharePoint pages.
List Views: Customized views of SharePoint lists or libraries embedded into SharePoint pages or dashboards.
These embedded containers make SharePoint more interactive and adaptable to organizational needs, enhancing collaboration and content management workflows.
2. Automating SharePoint Embedded Container Types with Microsoft Graph API
Using Microsoft Graph API, you can automate tasks such as creating or managing web parts, adding PowerApps to SharePoint pages, or modifying list views. Here are a few examples of how you can use Graph API for automation.
Example 1: Adding a Web Part to a SharePoint Page
One common use case for automating embedded containers is dynamically adding web parts to a SharePoint page. You can use the following Graph API call to add a web part programmatically.
API Request:
POST https://graph.microsoft.com/v1.0/sites/{site-id}/pages/{page-id}/webparts
Content-Type: application/json
{
"webPartId": "some-webpart-guid",
"position": {
"zoneIndex": 1,
"sectionIndex": 0
},
"properties": {
"title": "Document Library",
"libraryId": "document-library-id"
}
}
Explanation:
webPartId: The unique identifier of the web part you want to embed.
position: Determines where the web part will be placed on the page (in which zone and section).
properties: Allows you to configure the properties of the web part (e.g., a document library web part displaying a specific library).
Example 2: Embedding PowerApps into a SharePoint Page
You can embed a PowerApp into a SharePoint page using the Graph API by calling the following endpoint. PowerApps are great for adding custom functionality or workflows.
API Request:
POST https://graph.microsoft.com/v1.0/sites/{site-id}/pages/{page-id}/webparts
Content-Type: application/json
{
"webPartId": "some-powerapp-webpart-guid",
"position": {
"zoneIndex": 1,
"sectionIndex": 1
},
"properties": {
"powerAppId": "your-powerapp-id",
"title": "Custom App for Project Management"
}
}
Explanation:
powerAppId: The unique ID of the PowerApp you want to embed.
properties: Here, you can define the app and set a title for the embedded PowerApp.
This API allows you to automate the embedding of apps into your SharePoint sites, extending functionality and streamlining business processes.
Example 3: Automating List View Creation with Graph API
Another common automation task is creating custom list views. By embedding list views within a SharePoint page, you can present filtered or sorted data in a user-friendly format.
API Request:
POST https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/views
Content-Type: application/json
{
"displayName": "Custom View",
"columns": ["Title", "Created", "Modified"],
"query": "<Where><Eq><FieldRef Name='Status'/><Value Type='Text'>Completed</Value></Eq></Where>"
}
Explanation:
领英推荐
displayName: The name of the custom list view.
columns: The columns you want to display in this view.
query: The CAML query used to filter the view (in this case, showing only completed items).
This allows you to dynamically create and embed custom views based on organizational needs.
3. Automating SharePoint Embedded Containers with Power Automate
Power Automate provides a no-code/low-code environment that allows users to create workflows for automating various SharePoint tasks, including managing embedded containers like lists, libraries, and web parts. Power Automate flows can trigger actions based on certain conditions, such as when new items are added or when files are modified.
Example 1: Automating Web Part Updates with Power Automate
You can use Power Automate to automatically update or add web parts to a SharePoint page when a certain event occurs (such as when a document library reaches a certain number of files).
Step-by-step Workflow:
1. Trigger: Set up a trigger that initiates the flow when a file is added to a SharePoint document library.
2. Condition: Add a condition that checks the number of files in the library.
3. Action: If the condition is met, use an HTTP action to call the Graph API and embed a document library web part onto a specific SharePoint page.
Here’s how the HTTP action in Power Automate would look:
{
"method": "POST",
"url": "https://graph.microsoft.com/v1.0/sites/{site-id}/pages/{page-id}/webparts",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer {your-access-token}"
},
"body": {
"webPartId": "document-library-webpart-guid",
"position": {
"zoneIndex": 1,
"sectionIndex": 0
},
"properties": {
"libraryId": "your-library-id",
"title": "New Document Library"
}
}
}
Example 2: Embedding PowerApps Automatically Using Power Automate
Power Automate can also be used to automatically embed PowerApps onto a SharePoint page when a new app is created or updated. Here’s how you can set up a flow:
Step-by-step Workflow:
1. Trigger: Set up the trigger to activate when a PowerApp is created or updated.
2. Action: Use the HTTP action to call the Graph API and embed the PowerApp onto a SharePoint page.
This can help ensure that new or updated apps are instantly available for users without manual intervention.
4. Combining Graph API and Power Automate for Advanced Scenarios
You can combine Graph API and Power Automate for advanced automation scenarios in SharePoint. For instance, you can use Power Automate to trigger specific actions and then rely on Graph API to execute complex tasks, such as managing web parts, embedding PowerApps, or creating custom list views.
Example: Automating Custom List View Creation and Embedding
Let’s consider a scenario where every time a new project is created, a corresponding custom view is created and embedded into a SharePoint page.
1. Trigger: When a new project is created in a SharePoint list.
2. Action 1: Use Power Automate to create a custom view of the project list via the Graph API.
3. Action 2: Automatically embed this custom view into a specific page using Graph API via Power Automate.
By combining both tools, you can automate complex scenarios that save time and improve efficiency.
Summary
Automating SharePoint Embedded Containers using Microsoft Graph API and Power Automate can drastically enhance productivity and governance in your organization. Whether it’s embedding web parts, adding PowerApps to pages, or automating list views, these tools offer versatile and powerful ways to streamline SharePoint management.
By leveraging these APIs and automation tools, organizations can build dynamic SharePoint environments that are scalable, consistent, and tailored to meet their needs.
Co-Founder & Product Owner at Latenode.com & Debexpert.com. Revolutionizing automation with low-code and AI
2 个月Great post on SharePoint and Graph API integration! It's exciting to see how these tools are being leveraged to enhance data management and automation processes. With Power Automate, you can streamline workflows effortlessly. Additionally, platforms like Latenode offer AI-driven workflow creation, which helps reduce development time and make automation even more accessible. Keep up the good work in exploring these powerful automation solutions! ??