Saleforce聯繫人附件Visualforce
以下是在Visual force頁面中創建商機附件頁面的代碼。
從開發者控制台中選擇file new。
選擇Visualforce Page並插入代碼。
將文件另存為UploadAttachment.vfp
<apex:page standardController="Contact" tabStyle="Contact" extensions="UploadAttachmentController">
<apex:sectionHeader title="{!Contact.Name}" subtitle="Attach File"/>
<apex:form id="form_Upload">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!back}" value="Return to {!Contact.Name}"/>
<apex:commandButton action="{!back}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file_File"/>
<apex:inputFile id="file_File" value="{!fileBody}" filename="{!fileName}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Is the file for COMIT?" for="visible"/>
<apex:selectList value="{!selectedComit}" size="1" id="visible">
<apex:selectOption itemValue="false" itemLabel="No"/>
<apex:selectOption itemValue="true" itemLabel="Yes"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Subject" for="Subject"/>
<apex:inputTextarea id="subject" value="{!subject}" rows="1" cols="75"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Type" for="type"/>
<apex:selectList value="{!selectedType}" size="1" id="type">
<apex:selectOption itemValue="Contracts" itemLabel="Contracts"/>
<apex:selectOption itemValue="email" itemLabel="email"/>
<apex:selectOption itemValue="Expedited" itemLabel="Expedited"/>
<apex:selectOption itemValue="Finance" itemLabel="Finance"/>
<apex:selectOption itemValue="Legal" itemLabel="Legal"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="" for="uploadBtn"/>
<apex:commandButton id="uploadBtn" value="Attach File" action="{!processUpload}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>