Extract form attachments from submitted form data

Extract form attachments and send the attachments in an e-mail in power automate workflow.
The following video explains the steps needed to form attachments from the submitted data.

In this video, we will take a look at extracting the adaptive form attachments that are submitted to trigger and Microsoft Power Automate Workflow. As you can see on the screen I have a Power Automate workflow and the very first step in the workflow is the trigger point when a request is received to trigger this particular workflow. And in that request we had specified the schema here. So in this schema, the attachments are stored in an element called attachments.
So the next step we did was to initialize a variable. So this is the variable called email attachments and it is of type array. And in this variable we will add the attachments as we extract them from the submitted data.
Then we initialize another variable called form attachments. Again, it is of type array. And in this variable we will store the attachments that were submitted to this particular workflow. And remember, this attachments are stored in the element called attachments in the schema that we provided in the initial, in the first step of this workflow.
We then initialize the attachment array index. So this is of type integer and initial value is set to zero. And the name of the variable is called attachment array index. This index will be incremented as we loop through the attachments that were submitted through the Adaptive Form submission.
The next step is the construct apply for each. This is an out-of-the-box loop construct which Microsoft Power Automate provides. And in this construct we can loop through the attachments that were submitted. So the very first step is we need to take an input object and the input object is going to be the variable called form attachments, remember. So this variable will hold the attachments that were submitted from the Adaptive Form submission. Next step, we increment the index or the variable called attachment array index by value of one. So every time we loop through the number of attachments, this value will increment by one. Then we get hold of the current attachment. Again to get hold of the current attachment, there’s an out-of-the-box construct called the current item that will give you the current attachment object.
Then that current attachment object we convert it to a string using the string function here called string items apply for each. So that converts the attachment object into a string object. We then convert that string object into a JSON using the out-of-the-box JSON function that Power Automate provides. And then we parse the JSON. And to parse the JSON into an appropriate attachment object we need to provide the appropriate schema here. So this schema contains it’s own type object and it contains the properties file name, the data, content type and the size. So the data contains the actual data URI of the attachment that was submitted to this workflow. In the next step, we get the attachment file name. And to get the attachment file name, we simply, you can do it this way. This is a compose function. And in the parse JSON’s thing here you can simply add the file name here. So that would get you the file name of the current attachment that you’re iterating. So that’s the function, body, parse JSON, question mark, file name. So you don’t need to type this text. The moment you select the file name element from this parse JSON, you will get this particular text here. The next thing is to get the actual data URI of the attachment object. And that is again in the data element that we saw in the parse JSON object that we specified. It’s in the data element. Then we get the actual attachment object. To get the actual attachment object, we make use of the out-of-the-box function called data URI to binary. When we provide a data URI to that function, it returns you the binary object of that attachment. Then we add the attachment that we got into the array variable that we created earlier. So remember the array variable was called email attachments. And in that, we add the two elements. One is called a name and the value of that is going to be the attachment file name. And the content bytes is another element in the JSON object. And the value of that is the output get attachment object. So these two steps were done in the previous here. So this is the get attachment object here, and that’s the get attachment object. And that’s the get attachment file name. So that’s what we have done here, the output of those two functions. So once you have your email attachments populated with all the attachments, the next thing to do is to include that email attachment array in your email component here. And so the last step in the workflow is to include a component which will allow you to send the attachments that we created in that array. So I’ve used a send an email component version two. This allows me to include an array of attachments in the email body. The two addresses dynamically populated from one of the steps of the workflow. And if you want to improve the attachments dynamically created in that array, you’ll simply click on this button here, which allows you to switch to input an entire array. Click on that and then click on the attachments field here. And that will show you the two variables that we had created. So for the purpose of this demonstration, we have to use the variable called email attachments. Remember, this was the variable that we created, initialized. And then as we iterated through the loop, we appended the attachment object into this email attachment. So select that here. And now when you trigger this workflow when an adaptive form is submitted, you should get an email with the adaptive form attachments in the body of the email. -

The following is the attachment object schema that you need to use in the Parse JSON schema step

    "type": "object",
    "properties": {
        "filename": {
            "type": "string"
        "data": {
            "type": "string"
        "contentType": {
            "type": "string"
        "size": {
            "type": "integer"