You need to sign in to do that
Don't have an account?

Attachment List
I am working on trying to develop a class to display just the attachments on our Salesforce Instance. Kind of like the Attachment Manager that is available. However, I will be having it displayed in a VisualForce Page. Trying to query from the Database, but unsure of how to get the informaiton from all the attachments, not just related to a single case. Any ideas?
if you fetch body of attac hment too, you will get heap error. so avoid showing attachment body, or trim it to a small string.
in class create :
public List<Attachment> attchs{get; set;}
and fill this field in the class constructor
in vf page:
iterate over the above list using dataList.
All Answers
Also, I have this as a controller, I thought it would work but it seems to not be...
I think the issue is somewhere here:
what error you getting on your vf page?
Nothing, it is not returning any, and I know we have over 200,000 attachments.
can you provide your vf page code?
This is what I have as the VF page:
Any help would be great
class:
public with sharing class sid_attachment{
//page size
private Static Final Integer PAGE_NUMBER = 10;
public List<Attachment> attchs {get; set;}
//Search String used in ArticleList Tag
public String searchstring {get; set;}
public sid_attachment(){
String qryString = 'SELECT a.Name FROM Attachment a limit 500';
attchs = Database.query(qryString);
maxSize = attchs.size();
}
//Keeps track of current page & max size of article list
Integer currentPage = 1;
Integer maxSize = 1;
//returns wether we need to see previsions button or not
public boolean getPrevRequired(){
return currentPage > 1;
}
//Returns whether we need to see next button or not
public boolean getNextRequired(){
return currentPage * PAGE_NUMBER < maxSize ;
}
//Returns current page number
public Decimal getCurrentPageNumber(){
return this.currentPage;
}
//action for next click
public PageReference next(){
if(maxSize > this.currentPage * PAGE_NUMBER){
this.currentPage = this.currentPage +1;
}
return null;
}
//action for previous click
public PageReference previous(){
if(this.currentPage > 1)
this.currentPage = this.currentPage -1;
return null;
}
}
page:
<apex:page sidebar="false" title="Attachment List" controller="sid_attachment">
<style>
td{
vertical-align : top;
text-align: left;
}
</style>
<apex:form >
<apex:pageBlock title="Attachment List" >
<apex:panelGroup id="theSearchResults" >
<apex:panelGrid width="100%">
<apex:dataList var="a" value="{!attchs}" type="1">
{!a.name}
</apex:dataList>
</apex:panelGrid>
<apex:panelGrid columns="2">
<apex:commandLink action="{!previous}" value="Previous" style="{!IF(prevRequired =true,'display:block','display:none')}" reRender="theSearchResults"/>
<apex:commandLink action="{!next}" value="Next" style="{!IF(nextRequired =true,'display:block','display:none')}" reRender="theSearchResults"/>
</apex:panelGrid>
</apex:panelGroup>
</apex:pageBlock>
</apex:form>
</apex:page>
if you fetch body of attac hment too, you will get heap error. so avoid showing attachment body, or trim it to a small string.
in class create :
public List<Attachment> attchs{get; set;}
and fill this field in the class constructor
in vf page:
iterate over the above list using dataList.
Thank you Sidharth, that has corrected most of my issues. I appreciate your help.