Attachments in twig

The attachments stored in annotation entity are accessible using a special purpose-built URL:​​​​

where annotationid contains the record id of the record containing the attachment. For example

The following twig fragment displays a list of attachments for the current record (defined via entity binding):

{​​​​​% fetchxml collection="files" cache="PT30M" %}​​​​​
<fetch mapping="logical">
  <entity name="annotation" >
    <attribute name="annotationid" />
    <attribute name="filename" />
    <attribute name="mimetype" />
      <condition attribute="isdocument" operator="eq" value="1" />
<!- - optional condition filtering on entity typecode
      <condition attribute="objecttypecodename" operator="eq" value="salesorder" /> 
      <condition attribute="objectid" operator="eq" value="{​​​​​{​​​​​}​​​​​}​​​​​" />
{​​​​​% endfetchxml %}​​​​​
{​​​​​% for file in files.results.entities %}​​​​​
{​​​​​% endfor %}​​​​​