Adding Multiple Attachments Uploaded to a Form to an Approval

Options

Flow I created for our In-Kind gift forms is working great. However, I now need to tweak it a bit and have not been successful in figuring out how to do it.

When we receive an In-kind donation, the donor fills out a Microsoft Form on an iPad. We use the iPad to take a picture of the donation and upload it to the form. When the form is submitted, a flow is triggered to send an Approval to our team to review. The Approval contains all of the information from the form. The picture is attached to the Approval.

Now we want to attach multiple pictures. This is where I am having problems.

I attempted to create an Array variable and went through the steps I found online. The problem is the attachments are exceeding the size limit imposed by Microsoft for attachments on Approvals.

I created a String variable following the steps from this article, Solved: how can I add MULTIPLE attachments shared links in... - Power Platform Community (microsoft.com). However, there is still a problem. The links are live in the Approval card that sent via Teams but not in the Approval email.

How can I get the links to be live in the email as well?

or is there a better way to accomplish this?

Comments

  • Austen Brown
    Austen Brown Community All-Star
    Ninth Anniversary 1,500 Likes 1000 Comments Name Dropper

    @Susan Fioribello - My first thought is that you may need to put the links into the approval card in HTML using the <a href> attribute. Curious what @Alex Wong suggests.

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Austen Brown
    Approval action in flow doesn't use HTML, it uses Markdown, which is very different than HTML

    @Susan Fioribello
    I'm not sure where and what the situation is, so it is best you provide some screenshot of the flow run history that failed (the action that caused an error and the error message) and screenshot of the action in edit mode that failed.

    I am not sure how you are doing approval action, but you do not need to do attachment

    47063a1ac91ec47279cb9583cfb56da9-huge-im

    in the Details field, you can add links to the attachment (attachment is parsed with a sharepoint/onedrive location), which is what I thought you did in your previous post about handling file submitted in MS Form.

    the Markdown for creating a link is:

    [File Name of the Uploaded File](https://xxxxxxxx.sharepoint.com/path_to_your_file)

    for example:
    concat('[',first(body('Parse_JSON_Visit_Attendee_Spreadsheet'))?['name'],'](',first(body('Parse_JSON_Visit_Attendee_Spreadsheet'))?['link'],')')

    If you have more than one file uploaded, you can do a Apply to Each file uploaded, create a string variable to let you “append” to in the loop for each file.

  • @Alex Wong
    Hi Alex,

    This is section of the flow you helped me write to attach one picture. How can I edit it to allow for multiple pictures?

    In answer to your question: “in the Details field, you can add links to the attachment (attachment is parsed with a sharepoint/onedrive location), which is what I thought you did in your previous post about handling file submitted in MS Form.”

    Yes, this is correct. This is a sharepoint/onedrive location but it is a shared form. Not sure if that makes a difference.

    Do I still need the “Parse JSON 1 - Get First Picture"?

    60488ba38d6f01a645abe6de949b5612-huge-im
    09dfdb4bf3edb9a608f134b2a84701c5-huge-im
    b45aa3c71fc2cc3793382dacbcf486ba-huge-im
    ce4ed580fffd0f7f16d416829ebfa6c0-huge-im
  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Susan Fioribello
    the flow should be something like this (assuming the file upload is a required question)

    • trigger for form
    • get form response
    • initialize a string variable - Approval File Upload Markdown
    • Parse JSON of the answer to the upload question (JSON Schema to use)
      • {"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":{}}}}
    • Apply to Each File Uploaded dynamic content (loop through each file uploaded)
      • create a shared link
      • Append to the Approval File Upload Markdown String variable:
        concat('[',items('Apply_to_Each_File_Uploaded')?['name'],'](',ShareLink,'); ')
    • then somewhere in your Approval action, Details box, you will put the variable Approval File Upload Markdown
  • @Alex Wong
    I'm still not able to get this to work.

    327392fbb2054c64088da17fa4245902-huge-im
    eb50df42dce8134554aa08917822acc8-huge-im
  • @Alex Wong
    I cannot get this to work. Currently, I can't get passed this:

    Error message at top:

    “Action 'Get_file_metadata_using_path' failed: Unable to process template language expressions in action 'Get_file_metadata_using_path' inputs at line '0' and column '0': 'The template language expression 'decodeUriComponent(replace(body('Parse_JSON_Find_Picture')['link'],'https://rmhcnymetro.sharepoint.com/sites/GiftProcessingTeam', ''))' cannot be evaluated because property 'link' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.”

    Error message for Get file metadata using path:

    "InvalidTemplate

    Unable to process template language expressions in action 'Get_file_metadata_using_path' inputs at line '0' and column '0': 'The template language expression 'decodeUriComponent(replace(body('Parse_JSON_Find_Picture')['link'],'https://rmhcnymetro.sharepoint.com/sites/GiftProcessingTeam', ''))' cannot be evaluated because property 'link' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'."

    dcb960134f41fc1e820125b05da19d99-huge-im

    I searched the internet like crazy and nothing I have tried is working.

    BTW, the array variable is there because I was trying to make that work but it doesn't. When I add the array then the combined size of the attachments is too large.

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Susan Fioribello
    indead of body('Parse_JSON_Find_Picture')['link'] in the expression used in Get file metadata using path action

    since you are in an Apply to each array of uploaded file, you should be using

    items('Apply_to_each')?['link']

  • @Alex Wong
    Thanks Alex. The flow now works but there is still a problem.

    The links in Teams are clickable but when I click on them a new page opens in my browser with an error message:

    "This link has been removed.

    Sorry, access to this document has been removed. Please contact the person who shared it with you."

    The links in the email aren't clickable but if I copy and paste them into a browser I can get the picture.

    97c3a5c28efed85191447dfac37c130c-huge-im
    3fc2324cd9e4bf6dd611bf685bc42148-huge-im
    6c57e300b0095bf7da6a0bad3d0f6971-huge-im
    e855d76b92b7db4d35fbbd18e1eb60a9-huge-im
    4f633a4329ced80f7ea9f5832a909dfc-huge-im
  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Susan Fioribello
    Your screenshots looks correct to me and I just tested it and it works perfectly for me:

    d347489bbfe4ad8800ae6215f5801fe5-huge-im
    c630f4094b0becc7e1fb41573a2d51f6-huge-im
    c2f71393ef81af3c4cd4cdb9dd03751c-huge-im
    body('Parse_JSON_Uploaded_Files')
    24eee20c33768b756b0f7ec78b6f0a8c-huge-im
    decodeUriComponent(replace(items('Apply_to_Each_File_Uploaded')?['link'], 'https://xxxxx.sharepoint.com/teams/BusinessAutomation', ''))
    d77d8c0bdc4e735a52cc58904cd6ace4-huge-im
    outputs('Get_File_Metadata_Uploaded_File')?['body/ItemId']
    337fbe207362a5a3d2d631e5ad5deaf6-huge-im
    [@{items('Apply_to_Each_File_Uploaded')?['name']}](@{outputs('Create_Shared_Link_of_Uploaded_File')?['body/link/webUrl']})
    a1b5065093ec1f40cafabf0c1269a86b-huge-im

    Result:

    Approval in Teams:

    bf205b1464d3a7104382e71d864c05d8-huge-im
    both links works and takes to browser and showed images

    Approval in Outlook email:

    22eae13ba5c07609b0b155f7786bb179-huge-im
    link also works
  • @Alex Wong
    Here is what I am getting

    Teams

    3e0fcd657da64f51e7f7e237774a922c-huge-im

    Email (links are not clickable)

    9e170608e5f35ab986287be5666302c4-huge-im

    If I click on the link in Teams I get this but if I copy and paste the link I can get to the picture.

    7ff8dcb2cf986669f5d6dd560294ac0d-huge-im
  • @Alex Wong
    Never mind. I figured it out. I was using poor grammar.

    I mixed up the ( ) and the [ ] so instead of

    [Name](link)

    I was writing (Name)[Link]

    Now that I corrected it it works!

    Thank you for bearing with me. You ROCK!!!!

  • @Alex Wong
    I have a follow-up question for this process.

    Adding the multiple attachments has been working great; however, I have one flow that keeps failing. The only thing I can determine is that the attachment is a Word doc not a picture. I wrote the flow intending for Pictures.

    Could the problem be that it is a word document? If so, is there a way to fix it or do I need to limit the attachment type?

    Here is the Error message:

    Action 'Get_file_metadata_using_path' failed: File not found clientRequestId: 8e9c6083-f44c-495a-a82b-9924f9bd326b serviceRequestId: 3c0568a1-7097-7000-250d-0353031fccea

    Here is where the failure is occurring:

    c3abc79d97f327e7c56789268debe79d-huge-im

    This is the raw input for Apply to Each

    Apply_to_each

    {

    "foreachItems": [

    {

    "name": "Bethpage Freeport Branch Receipts_anonymous.docx",

    "link": "https://xxx.sharepoint.com/sites/GiftProcessingTeam/_layouts/15/Doc.aspx?sourcedoc={50A5CBC3-8766-4211-94F0-82BF5F2ECBCA}&amp;file=Receipts_anonymous.docx&amp;action=default&amp;mobileredirect=true",

    "id": "01N64KASGDZOSVAZUHCFBJJ4ECX5PS5S6K",

    "type": null,

    "size": 1256135,

    "referenceId": "01N64KASGG667HKVGFAZDJJFL25A7GHP3O",

    "driveId": "b!haxmJoZ3s0KHs_g2DBqWdC0JSAfJxddFh0ipKFhqTaXmXUf39q-XR4mdjLDll7xR",

    "status": 1,

    "uploadSessionUrl": null

    }

    ]

    }

    Get_file_metadata_using_path

    {

    "host": {

    "connectionReferenceName": "shared_sharepointonline",

    "operationId": "GetFileMetadataByPath"

    },

    "parameters": {

    "dataset": "https://xxx.sharepoint.com/sites/GiftProcessingTeam",

    "path": "/_layouts/15/Doc.aspx?sourcedoc={50A5CBC3-8766-4211-94F0-82BF5F2ECBCA}&file=Receipts_anonymous.docx&action=default&mobileredirect=true"

    }

    }

    In case it is relevant, here is the JSON

    Parse_JSON_Find_Picture

    {

    "content": "[{\\"name\\":\\"Bethpage Freeport Branch Receipts_anonymous.docx\\",\\"link\\":\\"https://rmhcnymetro.sharepoint.com/sites/GiftProcessingTeam/_layouts/15/Doc.aspx?sourcedoc={50A5CBC3-8766-4211-94F0-82BF5F2ECBCA}&amp;file=Bethpage Freeport Branch Receipts_anonymous.docx&amp;action=default&amp;mobileredirect=true\\",\\"id\\":\\"01N64KASGDZOSVAZUHCFBJJ4ECX5PS5S6K\\",\\"type\\":null,\\"size\\":1256135,\\"referenceId\\":\\"01N64KASGG667HKVGFAZDJJFL25A7GHP3O\\",\\"driveId\\":\\"b!haxmJoZ3s0KHs_g2DBqWdC0JSAfJxddFh0ipKFhqTaXmXUf39q-XR4mdjLDll7xR\\",\\"status\\":1,\\"uploadSessionUrl\\":null}]",

    "schema": {

    "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": {}

    }

    }

    }

    }

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Susan Fioribello
    The error message is pretty clear: “File not found”.

    Obviously the file uploaded exists, so meaning something is wrong in the input you provide to the Get file metadata using path action.

    You need to provide edit mode of Get file metadata using path action and a run history of this action. Your screenshot was not correctly giving info on this action, rather was on the condition action.

Categories