I have a Form that accepts a file attachment
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.
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:
As a workaround, I have implemented the subsequent HTTP PATCH request as per the above post.
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]'
}
}
Solved! Go to Solution.
Hi @steveebee ,
You could add a condition to check if there is an attachment or not. If yes , then to the apply to each.
Best Regards,
Bof
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:
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.
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.
Hi @steveebee ,
You could add a condition to check if there is an attachment or not. If yes , then to the apply to each.
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.