Two Easy Ways to Mark a Task as Complete in PowerApps: Patch & Teams Adaptive Cards
Are you managing tasks in PowerApps? Today, we’ve got two powerful approaches to marking tasks as complete—by using Patch within your app or by taking advantage of Microsoft Teams Adaptive Cards for a streamlined, collaborative update process. PowerApps and Teams work brilliantly together, and I’ll show you step-by-step how to implement both methods so you can pick the one that fits your workflow.
If you prefer to keep everything inside your PowerApp, that works great! But if your team often communicates and manages updates through Microsoft Teams, the Adaptive Cards with Power Automate will save you time and clicks. So let’s get started!
Method 1: Using Patch in PowerApps
In this approach, you’ll mark tasks as complete directly within your PowerApp using a button and Patch function. This method is fast and keeps everything centralized in your PowerApps environment. Here’s how it works:
Adding the “Mark as Complete” Button
To make this user-friendly, we need to let users confirm their actions before marking a task as complete. I’ve placed a confirmation popup over the task when users hit the “Complete” button. The button acts as a trigger, and the popup ensures the task isn’t accidentally marked due to a stray click.
Here’s how it flows:
- Trigger the Popup: When the “Mark as Complete” button is clicked, a container popup appears. This popup will ask the user to confirm if they really want to complete the task. The user has the chance to add comments or hit “Not Yet” if they’re not ready.
- Patch Functionality: If they choose “Yes,” we execute a Patch command in PowerApps. This updates the task’s status in your data source (which in my case, is a SharePoint list).
- Feedback to Users: After hitting complete, users get confirmation via a success message. If something goes wrong (errors), it shows those too.
Responsive Button Design
Building a responsive design is crucial, and PowerApps’ modern controls make it effortless. I’ve ensured the button looks clean, adjusts to different screen sizes, and aligns perfectly no matter the layout.
Here are the steps:
- Use containers and data card values to align button positions dynamically.
- Set the visible property of the button to only show when the task status equals “Approved.” This ensures the button doesn’t randomly appear when a task can’t be completed yet.
Using Variables to Control the Popup
I used a VAR_Complete variable for this. Here’s how it works:
- Clicking “Mark as Complete” sets this variable to
true
, displaying the popup. - Hitting the close button or “Not Yet” resets the variable to
false
, hiding the popup.
Within the Patch function, we capture useful metadata like:
- Status set to “Complete”
- User’s full name
- Timestamp of completion
- Optional comments
After everything is successfully patched, the task is updated, and the button disappears.
Example Patch Code:
Patch('TaskList',
LookUp('TaskList', ID = ThisItem.ID),
{
Status: "Complete",
FinalStatus: User().FullName & " completed the task on " & Text(Now(), ShortDateTime),
Comments: If(!IsBlank(txt_Comments.Text), "Comments: " & txt_Comments.Text, "No comments")
}
)
This approach ensures tasks are updated efficiently within PowerApps and automatically removes the “Complete” button when it’s no longer relevant.
Method 2: Using Microsoft Teams Adaptive Cards
Now let’s jump into using Teams Adaptive Cards. If your team uses Microsoft Teams to communicate and track progress, this method connects your PowerApp to Teams, allowing tasks to be marked complete without leaving the chat.
Overview of Teams Adaptive Cards
Here’s how it works:
- Receive the Alert in Teams: When an item needs approval or completion, an Adaptive Card is automatically posted in the Teams channel. This card includes task details like title, when it was created, and buttons to view more information or complete the task.
- Interacting with the Card: Users can directly mark the task as complete within Teams. If they choose “Complete,” they must add comments before submitting. Once completed, the card updates, showing everyone who marked it done, which helps the whole team stay in the loop.
- Behind the Scenes with Power Automate: The adaptive cards are built using Power Automate. It pushes relevant task information from PowerApps into Teams and waits for users to interact with the card.
Building the Adaptive Card
To create the card itself, we use the Adaptive Card Designer. This lets you drag and drop elements like text blocks, buttons, and input fields.
Key Components Include:
- Title and Creation Date: Pulled dynamically from the task in PowerApps or SharePoint.
- Buttons for Task Management: These include “View Details” (which can deep-link into the PowerApp) and “Complete/Not Yet.”
- Comments Section: This is where users need to provide feedback before completing a task.
Once the card is submitted, Teams sends the information back through Power Automate. Based on the user’s response, it updates the task inside PowerApps (or SharePoint in my case).
Setting Up in Power Automate
Power Automate links everything together:
- Trigger in Teams: When a task is assigned or nearing completion, the card notification is triggered.
- Conditional Logic: Based on user interaction (“Complete” or “Not Yet”), Power Automate updates the task status in the backend (like SharePoint).
This integration ensures communication remains seamless, and no team member is left wondering whether the task is still open.
Adaptive Card Code:
{
"type": "AdaptiveCard",
"version": "1.4",
"body": [
{
"type": "TextBlock",
"text": "${Title}",
"size": "Large",
"weight": "Bolder"
},
{
"type": "TextBlock",
"text": "Created by ${CreatedBy}",
"isSubtle": true
},
{
"type": "TextBlock",
"text": "Created on ${CreatedDate}",
"isSubtle": true
},
{
"type": "TextBlock",
"text": "${Brief}"
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "View Details",
"url": "${LinkToItem}"
},
{
"type": "Action.Submit",
"title": "Mark as Complete",
"data": {
"action": "complete"
}
}
]
}
Conclusion
Both methods offer distinct advantages depending on your workflow:
- The Patch method is perfect for teams who prefer to keep everything contained within PowerApps.
- The Teams Adaptive Card method is a smooth way to collaborate and communicate task updates directly in Teams chat, especially if that’s where your team hangs out most of the day.
Why not try both? Either way, you’re going to love how easy it is to manage tasks with these tools.
If you found this tutorial helpful, be sure to give it a thumbs-up, and drop your feedback in the comments below! I’d love to hear which method works better for your team and why! Keep building, keep exploring.
Until next time—keep rocking PowerApps like a pro!
news via inbox
Nulla turp dis cursus. Integer liberos euismod pretium faucibua