Friday 15 November 2013

View all your Attachment in Visualforce page

Hi Guys,

In your salesforce account you cannot view all your attachments in one place. You can only able to view attachment only record by records...

Instead of doing this you can view all your Attachment in single page using Visualforce page and Apex class...!

Here is the Code,

Apex Class :


public class AttachmentViewer
{
public List<Attachment> att{get;set;}

        
public AttachmentViewer()
{
att=[Select a.Id,a.ContentType,a.ParentId,a.Parent.Type,a.Parent.Name,a.OwnerId,
 a.Owner.Name, a.Name, a.LastModifiedDate, a.BodyLength From Attachment a];

}

}
 
Visualforce Page:
 
<apex:page controller="AttachmentViewer" showHeader="false">
<apex:form >
 <apex:pageblock id="account" title="Attachments" >
            <apex:pageblockTable value="{!att}" var="a">
            <apex:column headerValue="Download">
<apex:outputLink value="{!URLFOR($Action.Attachment.Download, a.Id)}" 
target="_blank">View</apex:outputLink>
            </apex:column>
           <apex:column value="{!a.Name}" headerValue="File Name"/>
           <apex:column value="{!a.BodyLength }" headerValue="Size"/>
            <apex:column value="{!a.Parent.Type}" headerValue="Object Name"/>
            <apex:column value="{!a.Parent.Name}" headerValue="Record Name" />
            <apex:column value="{!a.Owner.Name}" headerValue="Owner Name"/>
            <apex:column value="{!a.LastModifiedDate}"/>  
            </apex:pageblockTable>
  </apex:pageblock>
        
</apex:form>
        
</apex:page> 

1 comment:

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...