I have a working Flow which retrieves multiple attachments associated with a single record in a "Projects" Table. These attachments are saved in the Note Table in Dataverse.
After filtering the Note Table, I am using a Compose data operation to import these attachments using the following code:
{
"Name": @{items('Apply_to_each_3')?['filename']},
"ContentBytes": @{base64ToBinary(items('Apply_to_each_3')?['documentbody'])}
}
The output is then appended to an array variable.
Everything works fine, except when one of those attachments has been deleted (in a powerapps form where those attachments are displayed). When this happens, the record (for the deleted attachment) in the Notes Table seems to remain, only the output is "Null", which causes the base64ToBinary conversion to fail & the entire flow fails. For example in a record where two attachments remain, and one of those attachments has previously been deleted, the "apply to each_3" step attempts to run three times (instead of two). Two of those steps work, one of them fails with "Null" as the output.
If it helps, I am retrieving attachments by filtering the Notes Table with the following code (filtering by GUID of the projects Table):
_objectid_value eq @{items('Apply_to_each_2')?['cr6a2_projectid']}
How can I solve this? I imagine I would either have to avoid creating attachments in the Notes Table with Null as the content, or avoid retrieving those attachments with Null as the content...