In the world of enterprise application development, building a simple "Submit" form is only the beginning. Real-world business processes are dynamic; they require collaboration, auditing, and strict state management. One of the most common requirements I encounter when building apps for clients is the need for an Action Tracking System.
Imagine a scenario where a supervisor creates a log entry, and a team member needs to provide updates. You can't just overwrite the previous notes—you need a historical trail. Furthermore, once an action is marked as "Closed," the integrity of the data must be preserved. You don't want users adding comments or changing details after the fact.
In this guide, I’m going to walk you through a production-ready pattern for building a Comment and Status Control System in Power Apps. This isn't just a theoretical demo; this is a solution I have implemented in live environments to handle operational logging and incident management.
The Business Scenario
We are building an Action Tracker where the lifecycle of a record follows a strict path:
- Creation: A record is logged into a SharePoint list.
- Collaboration: While the status is "Open," users can view details and append comments.
- Completion: Once the task is finished, a user clicks "Close Action."
- Read-Only State: After closing, the "Save Comment" and "Close" buttons are disabled.
App Architecture
- Data Source: SharePoint Online (List Name:
Action_Tracker_Master) - Key Fields:
Status(Choice Column: Open, Closed)Comments(Multiple lines of text)LogID,LogDate, etc.
Designing the User Interface
A clean UI is essential for professional apps. We divide the View Screen into two areas:
- The Left Section: An Edit Form (View mode) showing core data.
- The Right Section: A custom "Communication Hub" for history and new notes.
Step 1: Navigating to the Record
In your Gallery (gal_ActionList), set the OnSelect property to:
Set(varCurrentAction, ThisItem);
Navigate(scr_ViewAction, ScreenTransition.None);
Step 2: Implementing the Multi-User Comment System
We solve the history problem by appending text to a single long-text column.
Displaying Existing Comments
Use a Text Input (e.g., txt_ViewComments):
- Mode: Multi-line
- DisplayMode:
DisplayMode.View - Default:
varCurrentAction.Comments
Adding New Comments
Use another Text Input (txt_AddComment). Set its DisplayMode to:
If(
!IsBlank(varCurrentAction) && Text(varCurrentAction.Status.Value) = "Open",
DisplayMode.Edit,
DisplayMode.Disabled
)
Step 3: The "Save Comment" Logic (Deep Dive)
Button: btn_SaveComment | OnSelect:
If(
!IsBlank(txt_AddComment.Value),
Patch(
Action_Tracker_Master,
varCurrentAction,
{
Comments: Concatenate(
Coalesce(varCurrentAction.Comments, ""),
If(!IsBlank(varCurrentAction.Comments), Char(10) & Char(10)),
User().FullName & " | " &
Text(Now(), "[$-en-US]hh:mm AM/PM | dd-mm-yy") & " : " &
txt_AddComment.Value
)
}
);
Refresh(Action_Tracker_Master);
Set(varCurrentAction, LookUp(Action_Tracker_Master, ID = varCurrentAction.ID));
Reset(txt_AddComment);
Notify("New comment added successfully!", NotificationType.Success),
Notify("Comment is required before submitting.", NotificationType.Error)
)
Step 4: Closing the Action
Set the OnSelect of "Close Action" button to:
Patch(
Action_Tracker_Master,
varCurrentAction,
{ Status: { Value: "Close" } }
);
Notify("Record has been closed.", NotificationType.Success);
Refresh(Action_Tracker_Master);
Navigate(scr_ViewAction, ScreenTransition.None);
Common Mistakes and Best Practices
Mistakes to Avoid:
- Hardcoding Names: Always use
User().FullName. - Forgetting Reset: Use
Reset(txt_AddComment)to clear the box.
FAQ Section
Q: Character limit?
A: SharePoint "Multiple lines of text" supports up to 63,999 characters.
Conclusion
Building a robust status control system transforms a simple tool into a professional business application. By combining Patch with conditional DisplayMode, you protect your data integrity.