File attachments are a core part of many Microsoft Power Pages experiences, whether users are submitting supporting documentation, collaborating through portal comments, or completing multi-step business processes. When file uploads work smoothly, they often go unnoticed. When they do not, they quickly become a source of frustration for both users and development teams.
Building a file-attachment solution that is secure, scalable, and easy to maintain is not always straightforward in Power Pages. Challenges often emerge around file size limits, reliability, error handling, and long-term support as requirements evolve. In this article, we outline a practical, proven approach for managing file attachments using Microsoft Power Automate, JavaScript, and Dataverse that is designed to improve reliability, support larger files, and reduce ongoing maintenance while delivering better user experience.
The Solution: A Combination of JavaScript and Power Pages
This approach is especially useful when native or simpler file-upload options begin to show limitations around reliability, scalability, or long-term maintainability in real-world Microsoft Power Pages implementations.

JavaScript: Preparing and Sending the File to Microsoft Power Automate
The first component of the solution is the client-side JavaScript executed when a user submits a file along with a Portal Comment (Note), or a user already has a Portal Comment (Note) that they want to attach.
- Capturing the File and the Portal Comment GUID
Begin by retrieving the file input element and extracting the file object that the user uploads. In this example, the file input element has an ID of fileInput:
const fileInput = document.getElementById("fileInput");
const fileAttached = fileInput.files[0];
This fileAttached object is then passed into the function that will handle sending it to your Power Automate flow (see attachFileToComment function above). The GUID for the related Portal Comment (Note) record is retrieved beforehand and supplied as part of that same call.
- Building the Attachment Function
The function responsible for attaching the file performs several necessary tasks:
- Accept the file and portal comment GUID as parameters
- Convert the file into Base64 so it can be serialized and transmitted
- Build the request payload with:
- The Base64 file content
- The Portal Comment GUID
- The file name
- Define the URL of the Power Automate flow that will receive the payload
- Execute an AJAX POST to send the structured data to Power Automate
Converting the file to Base64 ensures the content can be safely serialized and transmitted to Microsoft Power Automate using standard request payloads, without relying on custom APIs or unsupported integration patterns.
- Error Handling
Your JavaScript should also capture errors returned by the flow and surface them appropriately to the user interface. With this, the client-side portion of the solution is complete.
Power Automate: Handling the File Upload from Microsoft Power Pages


The Power Automate flow is responsible for receiving the input, storing the file in Dataverse, and returning a clean response back to Power Pages.
- Accepting Structured Input from Power Pages
The flow begins with the Power Pages trigger, configured to accept three inputs:
- request – a container for request body metadata
- commentGUID – the Dataverse identifier for the Portal Comment
- fileName – the name of the uploaded file
- Initializing a Standard Response Pattern
A single Compose action named response is added early in the flow.
Its structure is:
{ "status": "success" }
This creates a consistent, lightweight response definition that can be referenced at the end of the process.
- Uploading the Attachment to Dataverse
The core step uses the Dataverse “Add a new file” action to store the uploaded content directly in Dataverse.
Configuration:
- Table: Portal Comments
- Row ID: commentGUID
- Column: Attachment
- Content: Base64 payload from Power Pages
- Content Name: fileName
By relying on Dataverse's native file storage, this approach ensures:
- Proper file metadata handling
- Compatibility with large files
- Fewer permission-related issues
- Long-term sustainability compared to custom API endpoints
Using Dataverse’s native file capabilities also helps align file storage with existing security, governance, and data lifecycle practices already in place for the environment.
- Sending the Final Success Response
Once the file is uploaded, the flow updates the response to:
{ "response": "Success" }
The return value(s) to Power Pages action then returns this structured message to the JavaScript caller.
Conclusion
This combination of JavaScript and Microsoft Power Automate provides a robust and maintainable pattern for handling file attachments in Power Pages. By clearly structuring requests, explicitly defining schemas, and leveraging Dataverse’s built-in file column capabilities, teams can improve reliability and scalability without introducing unnecessary complexity.
More importantly, this approach gives organizations a foundation they can standardize and build on as portal usage grows, requirements evolve, and user expectations increase, helping to ensure file attachments support the overall solution rather than becoming a recurring point of friction.
Rachel Lowenstein – Technical Consultant
Working with New Dynamic
New Dynamic is a Microsoft Solutions Partner focused on the Dynamics 365 Customer Engagement and Power Platforms. Our team of dedicated professionals strives to provide first-class experiences incorporating integrity, teamwork, and a relentless commitment to our client’s success.
Contact Us today to transform your sales productivity and customer buying experiences.