cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SINX
Frequent Visitor

Append to Array fails when there are no files uploaded to Microsoft Forms Survey

Hello, I am receiving the following error when files are not uploaded on a Microsoft Forms Survey. Not all responses require a file attachment, so I really need the flow to work either way. I set up a condition to give it a path to go either to Yes or No if depending on upload or not, but now it hangs up in the Apply to Each and I am stuck. I have tried several different conditions in this section, but none seem to work, and I am wondering if I am going the right direction. I have learned a ton in these forums just with searches, so I am hoping the experts here can assist me on this one. Thank you all!!!

SINX_1-1623471654839.pngSINX_2-1623471703488.png

 

SINX_3-1623471748989.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SINX
Frequent Visitor

Unfortunately the above only caused a failure right at the Parse JSON. I did some further searching in the forums and found a method by another user here. @yashag2255  nailed it with his blog post at Working with Files on MS Forms in MS Power Automate (bythedevs.com)

 

If anyone wants to pare out the attachments from Microsoft Forms and send an automated email - this is the link you want to read! I have a survey for over 150 people that the results need to go to around 25different people in different combinations based on their region, role and supervisor. This works flawlessly to make it happen. Kudos to you. 

 

Thank you both for your assistance!

All the best!

View solution in original post

7 REPLIES 7
Serbay
Resolver I
Resolver I

Hi @SINX ,

You may try to add a compose action before 'Parse JSON'. 

-Add 'Compose' action, select the necessary function or dynamic content. Run the flow.

- Then use the output of 'compose' action in 'Parse JSON'
-Click 'Generate from sample' paste the output into 'Parse JSON'

If I have answered your question, please Accept the post as a solution. 

If you like my response, please give it a Thumbs Up. 

 

Regards,

Serbay

 

 

SINX
Frequent Visitor

Deleted duplicate response. 

SINX
Frequent Visitor

Thank you for the reply Serbay! I will give this a try, but could you please help me understand? What is the goal of the Compose Function in this case? The Parse JSON is working perfectly and pulling the attachments needed from the survey. The append to It is only when there are no attachments that it fails at the Apply to Each 2 / Append to Array Variable due to there being no files in the requested location. 

 

In the Condition to go to Append to Array I am using 

 

empty(body('Parse_JSON')) 
 
As the function to move to the next step if there were no results from Parse JSON. 

The goal of all of this is to generate an automated email to send with the attachments from the Forms Survey. When there are attachments, it works perfectly, when there are no attachments, it fails at the Append to Array Variable step, where it should go to the "Yes" Path and move to the next step which is to send the email. This picture is every step from the Parse JSON down to where it fails at the Append to Array Variable. 
 
Thank you!!!!
 
SINX_1-1623512950958.png

 


 

Serbay
Resolver I
Resolver I

Hi @SINX ,
It seems you should be handling NULL values for Parse JSON. By this NULL values passed will not cause an error. 
As an example :

"Name": {
"type": [
"string",
"null"
]
}


Regards,
Serbay

SINX
Frequent Visitor

Would I add this to this code in the Parse JSON? 

 

 "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"
        ]
    }
}

 

Serbay
Resolver I
Resolver I

hi @SINX ,

try to remove types ;

{

 

"type": "array",

    "items": {

        "type": "object",

        "properties": {

            "name": {},

            "link": {},

            "id": {},

            "type": {},

            "size": {},

            "referenceId": {},

            "driveId": {},

            "status": {},

            "uploadSessionUrl": {}

        },

        "required": [

            "name",

            "link",

            "id",

            "type",

            "size",

            "referenceId",

            "driveId",

            "status",

            "uploadSessionUrl"

        ]

    }

}

SINX
Frequent Visitor

Unfortunately the above only caused a failure right at the Parse JSON. I did some further searching in the forums and found a method by another user here. @yashag2255  nailed it with his blog post at Working with Files on MS Forms in MS Power Automate (bythedevs.com)

 

If anyone wants to pare out the attachments from Microsoft Forms and send an automated email - this is the link you want to read! I have a survey for over 150 people that the results need to go to around 25different people in different combinations based on their region, role and supervisor. This works flawlessly to make it happen. Kudos to you. 

 

Thank you both for your assistance!

All the best!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Top Solution Authors
Users online (2,808)