function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amy Crumbliss 9Amy Crumbliss 9 

Attachments are false empty in Visualforce Page

I think my syntax is correct, but attachments are empty even for Accounts with attachments.
 
<apex:page StandardController="Account" readOnly="true" recordSetVar="Accounts" showHeader="false" sidebar="false" cache="false">
    
    <apex:variable var="forceDomain" value="http://districtbridges.force.com" />
    
    <apex:repeat value="{!Accounts}" var="account" rows="1">
        <h3>Account: {!account.name}</h3><br />
        Attachments:<br />
        <apex:repeat value="{!account.Attachments}" var="att">
            - {!att.id} {!att.name}<br />
        </apex:repeat>
        EndAttachments<br />
    </apex:repeat>
</apex:page>



 
RD@SFRD@SF
Hi Amy,

The code seems alright, could you please try removing the rows="1" from the apex repeat  and try.

RD
Amy Crumbliss 9Amy Crumbliss 9
Thanks for the reply RD. Removing the rows="1" does not resolve the issue. I've confirmed that the first Account returned has an attachment, but the attachment array is empty.
Chirag MehtaChirag Mehta
Hi @Amy

Tried this at my end and Attachments are showing properly whether I keep rows or don't include rows attribute .. the code is repeating and showing attachments under each account (if present against that account).
  •  
  • Tried changing Accounts var to Accounts1
  • Tried changing class API version from 40 to 39 to 38
  • Tried adding/removing rows attribute
In all above cases, attachments are showing against accounts (if there's any against that account).

So not able to actually reproduce "attachment not showing" issue. Please advise if I'm missing anything. Thanks!

Chirag
Amy Crumbliss 9Amy Crumbliss 9
Thanks a lot for checking Chirag. Unfortunately, it's still not working for me and I have no idea why.
Brian Dombrowski 10Brian Dombrowski 10
We got it working by changing 'Attachments' to 'AttachedContentDocuments'.
 
<apex:page StandardController="Account" readOnly="true" recordSetVar="Accounts" showHeader="false" sidebar="false" cache="false">
    
    <apex:variable var="forceDomain" value="http://districtbridges.force.com" />
    
    <apex:repeat value="{!Accounts}" var="account" rows="1">
        <h3>Account: {!account.name}</h3><br />
        Attachments:<br />
        <apex:repeat value="{!account.AttachedContentDocuments}" var="att">
            - {!att.id} {!att.name}<br />
        </apex:repeat>
        EndAttachments<br />
    </apex:repeat>
</apex:page>



Explaination
This is expected behavior and due to Attachments being deprecated in Lightning Experience. Attachments are being superseded and replaced in favor of the more robust FILES feature. Hence what you thought is stored in ATTACHMENTS objects isnt actually right. Its being stored in CONTENTDOCUMENT object.

Read more @ https://help.salesforce.com/articleView?id=Attachments-are-not-returned-in-Lightning-Experience-search&language=en_US&type=1