You can follow below instructions to setup S-Drive for custom objects.
In this tutorial, you’ll:
- create a custom object (if you already have custom object created or planning to use S-Drive for a standard object you don’t need to create this).
- create a custom object file (another custom object to store S-Drive file information)
- create a visualforce page.
- Go to https://login.salesforce.com and login to your Salesforce account.
- Go to Setup -> Create -> Objects and click New Custom Object button.
- Provide Label as “DemoObject”, Plural Label as “DemoObjects”, Object Name as “DemoObject” and click Save button.
- Again go to Setup -> Create -> Objects and click New Custom Object button.
- Provide Label as “DemoObjectFile”, Plural Label as “DemoObjectFiles”, Object Name as “DemoObjectFile”, Record Name as “DemoObjectFile Number”, Data Type as “Auto Number”, Display Format as “A-{0000}”, Starting Number as “1” and click Save button.
- Once object is created, go to Custom Fields & Relationships section. Create following fields one by one by clicking New button and following on-screen instructions.
- Content Type
- Field Type: Text
- Field Label: Content Type
- Length: 255
- Field Name: Content_Type
- Description
- Field Type: Text Area (Long)
- Field Label: Description
- Length: 32,768
- Visible Lines: 3
- Field Name: Description
- File Name
- Field Type: Text
- Field Label: File Name
- Length: 255
- Field Name: File_Name
- File Size in Bytes
- Field Type: Number
- Field Label: File Size in Bytes
- Length: 18
- Field Name: File_Size_in_Bytes
- Parent
- Field Type: Master-Detail Relationship
- Field Label: Parent
- Related To: DemoObject
- Field Name: Parent
- Parent Folder Id
- Field Type: Text
- Field Label: Parent Folder Id
- Length: 255
- Field Name: Parent_Folder_Id
- File Size
- Field Type: Formula
- Field Label: File Size
- Formula Return Type: Text
- Field Name: File_Size
- Formula: IF(File_Size_in_Bytes__c > 1024,
IF(File_Size_in_Bytes__c > 1048576,
IF(File_Size_in_Bytes__c > 1073741824,
TEXT(ROUND((File_Size_in_Bytes__c /1073741824),2)) & ” GB”,
TEXT(ROUND((File_Size_in_Bytes__c /1048576),2)) & ” MB”),
TEXT(ROUND((File_Size_in_Bytes__c /1024),2)) & ” KB”),
TEXT(File_Size_in_Bytes__c) & ” bytes”)
- WIP
- Field Type: Checkbox
- Field Label: WIP
- Default Value: Checked
- Field Name: WIP
- Private (Optional)
- Field Type: Text
- Field Label: Private
- Default Value: Unchecked
- Field Name: Private
- Content Type
- For the next step, we need to create a visualforce page. Go to Setup -> Develop -> Pages and click New button.
- Type Label and Name as “DemoObjectPage” and paste below content into the Visualforce Markup section:
<apex:page standardController="DemoObject__c" tabStyle="DemoObject__c"> <apex:detail inlineEdit="true" relatedList="true" showChatter="true"/> <cg:AttachmentComponent title="DemoObject Files" inline="true" customObjectName="DemoObject__c" customObjectFileName="DemoObjectFile__c" objectId="{!DemoObject__c.Id}" /> </apex:page>
- You can modify the page content and AttachmentComponent properties based on your needs (refer to the Component Reference in page edit page) and Save the page.
- Again, go to Setup -> Develop -> Pages and click Security link next to the DemoFilePage and select profiles that you want this page to be visible.
- Go to Setup -> Create -> Tabs. Click New under Custom Object Tabs. Select “DemoObject” for the object and a tab style and Save the tab.
- Go to Setup -> Create -> Objects. Click DemoObject link.
- Scroll to the Page Layouts section and click Edit next to the “DemoObject Layout” item. Remove DemoObjectFiles related list and Save the layout.
- Scroll to the Buttons, Links, and Actions section and click Edit next to the View label.
- Select Override With Visualforce Page and then select DemoObjectPage [DemoObjectPage] from the dropdown. Click Save button.
- Go to DemoObjects tab and select/create a demo object. Scroll to the bottom of the demo object detail page. You’ll see DemoObject Files section.
- Now you can create folders, upload files etc. to your demo objects using S-Drive.