Hi,
I've been struggling with a client requirement where they need external customers to be able to upload an image of an insurance card on a Marketing Form. I understand that the marketing forms do not currently have this option and I'm trying to avoid Portals, mainly because I've already built the form for them within Marketing and I don't want to have to build out the entity forms and so on. I've read that there are ways to extend marketing forms and so I'm trying to implement an option where I would have a file repository in Flow using "When a HTTP request is received" and then somehow send to that from the form. However, I'm struggling with how to extend the Marketing form to send to that endpoint as well as have the "file upload" option display on the form. Is there a way to do this or am I stuck with having to rebuild within Portals?
Hi,
Thank you for your sharing. It broadened my thoughts.
Best Regards,
Nya
After countless hours of googling and trial and error, I finally found a solution. I'm just posting this for anyone who is trying something similar and isn't finding any detailed help. It's certainly not an elegant solution since I'm fairly new to development but it does work. The solution is to create a small form on the Marketing page where the Marketing form exists. This form will include the file upload, the email field, and the URL from the "When an HTTP Request is Received" flow. The email value serves as the key you can use in the Flow to search Dynamics for the person who uploaded the file and then you can include the uploaded file as a Notes attachment. There might be an easier solution someone knows where you can somehow include this in the Marketing form submission itself and POST the details to Flow but I wasn't able to do it.
I figured out a way to get it to post the uploaded file to my Flow HTTP Request which is great but now I'm trying to understand how to connect it back to the submitter. Right now it just posts the file out to the repository and then my idea was to have Flow post it to Dynamics but I need the submitter information included. How can I do that?
I found some code that got me really close. It lets me post to the HTTP Request from the Marketing Form like I want but I can't seem to get it to send the actual file that was uploaded when I was in the form. I've been searching for an example of how to do that piece but I can't seem to find anything that really matches what I need. Here's what I've got so far that does at least go out to the endpoint. What I'm missing is code that will tell it how to pull the file I upload and then send that data out to Flow:
<input type="file" accept="image/*" onchange="openFile(event)"><br>
<img id="output">
<script>
var openFile = function(event) {
var input = event.target;
var reader = new FileReader();
reader.onload = function(){
var dataURL = reader.result;
var output = document.getElementById('output');
output.src = dataURL;
};
reader.readAsDataURL(input.files[0]);
};
const xhr = new XMLHttpRequest()
xhr.open('POST', '<myflowHTTPRequestURL>')
xhr.send('output')
</script>
Yes I've seen those articles and the first one did help me setup the HTTP Request flow but I can't figure out how to get the FileReader.readAsDataURL() to work within the javascript on the form's page. I tried using the article as a guide but it doesn't do anything when I submit. Do you have an example of this working that you can point me to? I haven't been able to find someone who actually did this.
Hi,
Please refer to the following article to build a files processing service endpoint with Flow.
Accept HTTP Requests in a Flow and send Response back | Power Automate | D365 Demystified
And then read uploaded files via FileReader.readAsDataURL() method in the page which contains your marketing form to extract file's data in base64 encoded string format and send data to the endpoint.
FileReader.readAsDataURL() - Web APIs | MDN (mozilla.org)
If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.
Best Regards,
Nya
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156