You need to sign in to do that
Don't have an account?
VF n CONTROLLER ATTATCHMENT
CONTROLLER
public class EmployeeRelatedList {
private Empolyee_Details__c empDetail;
public Transient Blob fileBody {get;set;}
public String fileName {get;set;}
publlic string ID{get; set;}
public EmployeeRelatedList(ApexPages.StandardController stdController) {
this.empDetail = (Empolyee_Details__c)stdController.getRecord();
}
public Pagereference save() {
try{
if(fileBody !=null && fileName !=null)
{
Attachment myAttachment = new Attachment();
myAttachment.Body = fileBody;
myAttachment.Name = fileName;
myAttachment.ParentId = at.Id;
}
upsert empDetail;
return new Pagereference('/apex/Custom_pagenations');
}
catch(Exception e){
Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, e.getMessage()));
return null;
}
}
}
VF PAGE
<apex:page standardController="Empolyee_Details__c" extensions="EmployeeRelatedList" tabStyle="Empolyee_Details__c">
<apex:form >
<apex:sectionHeader title="EmployeeInfo"/>
<apex:pageBlock title="EmployeeData">
<apex:pageBlockSection title="Empolyee basic Details" columns="2" collapsible="false">
<apex:outputField value="{!Empolyee_Details__c.EmpId__c}"/>
<apex:inputField value="{!Empolyee_Details__c.FirstName__c}"/>
<apex:inputField value="{!Empolyee_Details__c.LastName__c}"/>
<apex:inputField value="{!Empolyee_Details__c.MiddleName__c}"/>
<apex:inputField value="{!Empolyee_Details__c.DateofBirth__c}"/>
<apex:inputField value="{!Empolyee_Details__c.FatherMotherhusbandName__c}"/>
<apex:inputField value="{!Empolyee_Details__c.MartialStatus__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Empolyee office Details" columns="2" collapsible="false">
<apex:inputField value="{!Empolyee_Details__c.Current_Designation__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Current_Office__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Current_Cadre__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Present Address Detail" columns="2" collapsible="false">
<apex:inputField value="{!Empolyee_Details__c.Present_Address__c}"/>
<apex:inputField value="{!Empolyee_Details__c.State__c}"/>
<apex:inputField value="{!Empolyee_Details__c.District__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Phone_Number__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Mobile_Number__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Pin_Code__c}"/>
<apex:inputField value="{!Empolyee_Details__c.E_mail_if_any__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Perment Address Detail" columns="2" collapsible="false">
<apex:inputField value="{!Empolyee_Details__c.Permanent_Address__c}"/>
<apex:inputField value="{!Empolyee_Details__c.State_p__c}"/>
<apex:inputField value="{!Empolyee_Details__c.District_p__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Pin_Code_p__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Phone_Number_p__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Mobile_Number_p__c}"/>
</apex:pageBlockSection>
<apex:pageblockSection title="Joing Details" collapsible="false">
<apex:inputField value="{!Empolyee_Details__c.Date_of_Joining__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Date_of_Leaving__c}"/>
</apex:pageblockSection>
<apex:pageBlockSection title="Basic" collapsible="false">
<apex:inputField value="{!Empolyee_Details__c.Education__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Name_of_Board_University__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Marks_Obtained_In__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Passing_Year__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Stream__c}"/>
<apex:inputField value="{!Empolyee_Details__c.Grade__c}"/>
</apex:pageBlockSection>
<apex:outputLabel value="File" for="file"/>
<apex:pageBlockSectionItem >
Attachment <apex:inputFile id="fileSize" value="{!fileBody}" filename="{!fileName}" />
</apex:pageBlockSectionItem>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="SAVE"/>
</apex:pageBlockButtons>
<apex:inputfile value="{!Empolyee_Details__c.id}"></apex:inputfile>
</apex:pageBlock>
</apex:form>
</apex:page>
Hi
For above code i got errors.The above code is for EMPLOYEE CREATE PAGE.In that i add one more ATTATCHMENT File .i got errors while uploading the file.please slove the issue.
Thanks&Regards
RangaReddy
NOTE: When adding code please use the "Add a code sample" button (icon <>) to increase readability and make it easier to reference.