cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
steveebee
Regular Visitor

saving attachments (URLs) submitted via a Form into a List

I have a Form that accepts a file attachment

2022-08-15_8-09-56.png

which, when submitted, stores the file in the following location

https://[domain]/sites/RDTeam/Shared%20Documents/Apps/Microsoft%20Forms/Data%20Request%20(BETA)/Include%20a%20copy%20of%20the%20last%20time%20you%20received%20this

and triggers a Flow that writes the contents of the Form to a List.

 

2022-08-15_8-16-40.png

 

However, placing the corresponding Form object into the Attachment field of the List generates an OpenApiOperationParameterTypeConversionFailed error. As explained here, this does not work since a List's Hyperlink field type has two parts:

 

Snag_7fa4b761.png

 

As a workaround, I have implemented the subsequent HTTP PATCH request as per the above post.

2022-08-15_8-31-06.png

The Flow now executes without generating an error, but the URL and Description are obviously hard-coded in this example. I'd like this instead to pull from the values submitted through the Form.

 

My question is: How do I reference the "name" and "link" attributes of the object coming from the Form so that I can dynamically populate the Description and URL values of the JSON for storing something like this Web Colors.pdf in the Attachment column of my List?

 

 

{
    '__metadata': { 'type': 'SP.Data.Data_x0020_RequestListItem' },
    'Attachment': {
        '__metadata': { 'type': 'SP.FieldUrlValue' },
        'Description': '[name]',
        'Url': '[link]'
    }
}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @steveebee ,

 

You could add a condition to check if there is an attachment or not. If yes , then to the apply to each.

 

vbofengmsft_0-1660700069115.png

 

Best Regards,

Bof

 

View solution in original post

4 REPLIES 4
v-bofeng-msft
Community Support
Community Support

Hi @steveebee ,

 

Please try:

vbofengmsft_0-1660628006063.png

 

Best Regards,

Bof

 

steveebee
Regular Visitor

Thanks @v-bofeng-msft for the tip. This works when there's an uploaded file, but since this is an optional Form component, when no file is uploaded, it errors:

 

 

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@json(outputs('Get_response_details')?['body/re91e016ce99a460191220ef95c992df5'])' is of type 'Null'. The result must be a valid array.

 

 

This is what I've got set up now:

 

steveebee_0-1660670008463.png

 

The Flow can now dynamically reference (1) the filename and (2) its SharePoint URL as created by the Form submission and, in turn, writes this into the List's Attachment column with the proper values assigned to the two parts of the Hyperlink data type.

 

steveebee_2-1660671018610.png

 

BTW, for others looking in, to obtain the unique identifier used in the above json() expression, I temporarily placed the Form object in question - the one that accepts the uploaded file - into the Create item step and hovered over it to view the tool tip.

 

steveebee_1-1660670364822.png

 

Hi @steveebee ,

 

You could add a condition to check if there is an attachment or not. If yes , then to the apply to each.

 

vbofengmsft_0-1660700069115.png

 

Best Regards,

Bof

 

Thank you. Yes, testing the same json() expression for a null value in a conditional step and moving the Apply to each step into the No branch properly handles this issue.

 

2022-08-19_20-37-05.png

  

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,388)