Why?
Ever since the December 2019 announcement on improvements to data storage in Common Data Service announcing the File and Image data type, I have been waiting for it to be fully functional. As these improvements yet have to allow more than one attachment per added Field, I am still using the traditional relationshop to the Note (Annotation) entity for storing (multiple) attachments on one Entity and sometimes you want to get all those related files in a Power Automate Flow 😎
What?
This post will show you how to setup an Entity to make use of the traditional attachment functionality within the Common Data Service (CDS) and then let a Power Automate Flow get those attachments related to an Entity record.
How?
1) The first thing is to create an entity that has attachments enabled:

This creates a one-to-many-relationship (1:n) of your entity with a very special Entity in the CDS named Notes also known as Annotations. You can verify this by looking at the Relationships tab of your entity:

TIP: from the Relationships tab you can click in a related Entity to go directly to the configuration page of that Entity 💡.
2) When we realize that this default functionality to handle attachments of a CDS record is setup as a 1:n relationship, we know we can list all related records using the List records action of the CDS Connector. We just have to use the Notes for the Entity name and use a filter query on the _objectid_value property of this Entity:

Formula for the Filter Query:
_objectid_value eq @{triggerOutputs()?['body/crcef_djinvoiceid']}
Now when the Flow runs on a record with multiple attachments:

it gets all related files:

Next post will show on how to use the attachments listed in the Flow 💪
2 thoughts on “Power Automate: Get Common Data Service Files related to an Entity”