2

Tried to enable users to add attachments to a NewCase VF page, but the attachments section is not showing.

Here is my code:

<apex:page standardController="Case">


<apex:form >

<apex:pageBlock title="New Salesforce Case" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Submit"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Salesforce Case -- Red lines represent required fields." columns="1">


Please click the lookup icon (small button to right of field) to search name selection from Salesforce lookup dialog.    <br></br>

            <apex:inputField value="{!case.ContactId}" required="true" label="Requestor Name" />
            <apex:inputField value="{!case.Contact.Phone}" required="true" label="Phone" />
            <apex:inputField value="{!case.Contact.Email}" required="true" label="Email" />
            <apex:inputField value="{!case.Type}" required="true"/>
            <apex:inputField value="{!case.Priority}" required="true"/  >         
</apex:pageBlockSection>

<apex:pageBlockSection title="Case Details" columns="1">
            <apex:inputField value="{!case.ARC_Department__c}" required="true"/> 
            <apex:inputField value="{!case.Salesforce_Object__c}" required="true"/> 
            <apex:inputfield value="{!case.Requested_Completion_Date__c}" required="false" />      
            <apex:inputField value="{!case.Description}" style="width:50%;" required="true"/>
</apex:pageBlockSection>

</apex:pageBlock>


</apex:form>

<apex:relatedList list="CombinedAttachments" title="Attached Screenshots"/>

</apex:page>
3

You won't be able to get the related list to display on a New record page, because there's not yet a record ID to drive the selection of the Attachments. If you look at your page with an ?id=[CaseID] parameter, using an existing Case ID in your dev/sandbox org, you'll see the related list, even if there aren't any attachments on the record.

You'll need a controller extension and some additional Visualforce to accept attachments on create. The link that Santanu posted covers the case where the parent of the Attachment already exists, but could serve as a starting point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.