Voici le code permettant de créer la page de pièce jointe de l’opportunité dans la page force visuelle.
Dans la console du développeur, choisissez Fichier Nouveau.
Sélectionnez Visualforce Page et insérez le code.
Enregistrez le fichier sous le nom UploadOpportunityAttachment.vfp.
<apex:page standardController="Opportunity" tabStyle="Opportunity" extensions="UploadOpportunityAttachmentController">
<apex:sectionHeader title="{!Opportunity.Name}" subtitle="Attach File"/>
<apex:form id="form_Upload">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!back}" value="Return to {!Opportunity.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>