You need to sign in to do that
Don't have an account?
CvrK
Is it possible to provide Notes and Attachments option in VF Page(Web form)?
Hi Everyone,
Is there any way out there to provide Notes and Attachment option in VF Page(Web form),so that when users try to submit requests for the case object using web form they can enter the notes and upload related attachment along with the field values,which helps the support people to process their request,
Currently what i have in mind is, creating a Description(Text Area) field and making it availablle for then web form.just wondering if there is any better solution than my idea. Please provide me any sample code if possible.
Thanks
Cvrk
Is there any way out there to provide Notes and Attachment option in VF Page(Web form),so that when users try to submit requests for the case object using web form they can enter the notes and upload related attachment along with the field values,which helps the support people to process their request,
Currently what i have in mind is, creating a Description(Text Area) field and making it availablle for then web form.just wondering if there is any better solution than my idea. Please provide me any sample code if possible.
Thanks
Cvrk
<apex:sectionHeader title="Visualforce Example" subtitle="Attachment Upload Example"/>
<apex:form enctype="multipart/form-data">
<apex:pageMessages />
<apex:pageBlock title="Upload a Attachment">
<apex:pageBlockButtons >
<apex:commandButton action="{!upload}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection showHeader="false" columns="2" id="block1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="File Name" for="fileName"/>
<apex:inputText value="{!attachment.name}" id="fileName"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Description" for="description"/>
<apex:inputTextarea value="{!attachment.description}" id="description"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
and controller is
public with sharing class AttachmentUploadController {
public Attachment attachment {
get {
if (attachment == null)
attachment = new Attachment();
return attachment;
}
set;
}
public PageReference upload() {
attachment.OwnerId = UserInfo.getUserId();
attachment.ParentId = '0037000000lFxcw'; // the record the file is attached to
attachment.IsPrivate = true;
try {
insert attachment;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
return null;
} finally {
attachment = new Attachment();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
return null;
}
}
I hope this is helpful for you
Error:Error uploading attachment