cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
h4X6
Helper I
Helper I

Help with uploads in forms and emailing out

Hello everyone

 

I have been racking my brain with this for days/weeks, I have tried so many tutorials, and guides but nothing seems to work.

 

I have a form, set up for end user to submit a ticket for help (help desk IT ticket). They have to complete questions, give information, etc. and one of the questions is if they have an image or screenshot to share to upload it to the form (using the upload file option on MS Forms).

 

Well, this is where I am stuck. I do not care if the upload is attached to the email or just a link to view it. What I am running into issues with is when there is nothing attached, it errors out. I have tried various conditions, and nothing seems to work.

 

Essentially, what I am trying to do is as follows:

 

Completed form + attachment = emails out

Completed form + no attachment = emails out

 

Any guidance or help would be appreciated... Like I said, I can get everything to work perfectly IF there is an something uploaded, where it errors out is when there is nothing uploaded.

 

Thank you in advance!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

I wrote a step by step walkthrough on exactly this topic  The blog article is here:

Emailing File Attachments from Forms with Power Automate – What Me Pa..Panic? (dontpapanic.com)



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Hey @h4X6 

 

Please review the video tutorial below-

 

https://www.youtube.com/watch?v=kNC8q6NzBEc 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

26 REPLIES 26
h4X6
Helper I
Helper I

here is an image of my flow so far and where it is failing when there is no upload

h4X6_0-1618614576664.png

And this is the flow when there is an upload

h4X6_1-1618614655032.png

 

In addition, I am getting 1 email per upload. If there are 3 uploaded files, I get 3 separate emails.

Pstork1
Dual Super User III
Dual Super User III

I wrote a step by step walkthrough on exactly this topic  The blog article is here:

Emailing File Attachments from Forms with Power Automate – What Me Pa..Panic? (dontpapanic.com)



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

h4X6
Helper I
Helper I

Thank you for this. Does this almost mean that the flow won't fail is there is nothing uploaded? My issue is primarily she. Someone submits the form and there is nothing uploaded. That's when it fails.

Pstork1
Dual Super User III
Dual Super User III

The walkthrough doesn't cover that, but its easy enough to add a condition to check whether there are or aren't attachments uploaded.  Just check the length of the array output from the Parse Json.  If its not greater than 0 then there are no files.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
h4X6
Helper I
Helper I

edit: delete

h4X6
Helper I
Helper I

edit: delete

h4X6
Helper I
Helper I

edit: delete

h4X6
Helper I
Helper I

Edit:

 

I have it working with multiple uploads now... but still failing when there is nothing uploaded:

 

h4X6_3-1618634146556.png

 

For reference the JSON Schema I am using is:

 

 

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
            },
            "link": {
                "type": "string"
            },
            "id": {
                "type": "string"
            },
            "type": {},
            "size": {
                "type": "integer"
            },
            "referenceId": {
                "type": "string"
            },
            "driveId": {
                "type": "string"
            },
            "status": {
                "type": "integer"
            },
            "uploadSessionUrl": {}
        },
        "required": [
            "name",
            "link",
            "id",
            "type",
            "size",
            "referenceId",
            "driveId",
            "status",
            "uploadSessionUrl"
        ]
    }
}

 

 

At this point obviously something is wrong with the JSON, i just cannot see what...

 

It only fails on the parse json when there are no uploads to the form, but everything works as expected when there is an uploaded file(s).

 

Thanks again everyone!

Pstork1
Dual Super User III
Dual Super User III

Check the length() of the question used for uploading the file before you do the parse JSON.  If its not greater than 0 then there are no files attached.  If it is greater than 0 then parse the JSON and do the rest.  If its not send the email without the attachments.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
h4X6
Helper I
Helper I

Hey

Thank you for the reply. I'm sorry but that confused me. How do I see the length() of the question ?

 

Are you saying more the condition to be before the parse JSON? I thought of that but it errors out saying the condition needs to be after as it doesn't know where the JSON is

Pstork1
Dual Super User III
Dual Super User III

When you get the response details from the form the answers to each question will be available as dynamic content.  Use the expression tab to add a length() function and insert the specific question used for the uploads into that function. I'm sure my questions are different but it should look something like this.  If there are no uploads in response to that question it will be blank.  In my case I didn't have to do any of that because I made the file upload question required.  A user couldn't submit the form unless they uploaded a file.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

So I need to enter the dynamic content of the question for the upload in the brackets after the length expression?


And then in the 2nd field enter "is greater then" followed by 0 in the 3rd field?

Pstork1
Dual Super User III
Dual Super User III

Inside the Length expression.  If the length of the response to that question is 0 then there are no files uploaded.  Otherwise correct.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hey mate @h4X6 

 

You an use to check if the there no attachments uploaded with the condition below-

 

empty(<your attachment variable>)
 
CFernandes_0-1618678320342.png

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 
 

 

h4X6
Helper I
Helper I

And just to confirm. The condition is put after parse JSON, correct? I ask as the flow fails on the parse JSON when there is no uploaded file and not on the condition

Pstork1
Dual Super User III
Dual Super User III

The condition is put before the Parse JSON.  You use it to see if there are any files that need to be parsed. If the question answer doesn't have any files then as you've seen the Parse won't work.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Just to back up @Pstork1  answer. Here is the screenshot..

 

CFernandes_0-1618688138450.png

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

h4X6
Helper I
Helper I

edit: im an idiot, and had the parse JSON there 2 times... standby

 

Edit 2:

So looks like its wokring without the upload now, which is nice

 

Uploads are not, its erroring out at on the send email portion:

 

h4X6_1-1618702512030.png

 

h4X6_2-1618702538279.png

 

Pstork1
Dual Super User III
Dual Super User III

YOu need to have the Send an email in both the yes and No side of the condition.  The only difference will be that in the No side you won't load the FileArray variable into attachments, since there are no attachments.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Users online (54,472)