The standard mechanism of attaching files to Salesforce records navigates the user away from the record to a dedicated upload page. This leaves the user unable to see if they are duplicating an existing attachment, or see the exact details of any fields that may be required to name the attachment correctly.
In this recipe, we will create a Visualforce page to allow a user to attach files directly to a contact record, displaying fields from the record and details of any existing attachments.
This recipe makes use of a custom controller, so this must be present before the Visualforce page can be created.
Navigate to the Apex Classes setup page by clicking on Your Name | Setup | Develop | Apex Classes.
Click on the New button.
Paste the contents of the
AttachmentsExt.cls
Apex class from the code download into the Apex Class area.Click on the Save button.
Next, create Visualforce page by navigating to the Visualforce setup page by clicking on Your Name...