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
PuranKishorePuranKishore 

Can any one tell me the apex code for searching a file in account?

AppyAppy

VF Page Code 

<apex:page controller="filesearch">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:inputText label="Enter FileName ::" value="{!filename}"/>
<apex:commandButton value="Search" action="{!searchitem}"/>

<apex:pageBlockTable var="item" value="{!test}">
<apex:column value="{!item.Name}" headerValue="Attachement Name"/>
</apex:pageBlockTable>

<apex:pageBlockTable var="item" value="{!acclist}">
<apex:column value="{!item.Parent.Name}" headerValue="Account Name"/>
<apex:column value="{!item.Name}" headerValue="Attachment Name"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>


Apex Code

public class filesearch
{

public string filename {get; set;}
public list<attachment>acclist {get; set;}
public list<attachment> test{get; set;}

public filesearch(){
test= test();
}

public list<attachment> test()
{
test= new list<attachment>();
test = [SELECT name from Attachment];
return test;
}

public PageReference searchitem()
{
acclist = new list<attachment>();
acclist = [Select a.Parent.Name, a.ParentId, a.Name From Attachment a where a.Name=:filename];

return null;
}


}