Global Table Actions: Attach a File

Warning

Original components are not available in API version 2 pages. Use Ink components instead.

This tutorial shows how to create a table of attached files with an Upload button. In Steps 1-2, we’ll create an Attachments table on an Account Detail Page. (We’re going to breeze through this process, so for more detailed instructions, you can check out the tutorial about Attaching Files to a Record, Steps 3-9.) Then, starting in Step 3 we’ll zoom in on the process of creating a Global Action that will enable you to attach a file using the standard Salesforce attachment page.

Step 1: Create an Attachments model.

image0

  1. Create a Model on the Attachment object.
  2. Click to add a Condition.
  3. For your condition, make the Attachment Parent = the id parameter in the page’s url. (For value, you can also choose “Field from another model” > Account > Id.) For more help on Conditions, see the Conditions tutorial.

Step 2: Create an Attachments Table.

image1

  1. Click on Components to drag in a Table. You can also drag in the Tab Set component to organize the related lists on this page.
  2. Click on your table and set it to the Attachments Model (very important - otherwise you won’t be able to drag Attachment fields into this table).
  3. In the Attachments Model, click to select your desired fields, and drag and drop them into the table.

Step 3: Click Add Features > Add Global Action. ===

image2

Step 4: Click on your new action and edit its properties. ===

image3

  1. Click on your new action.
  2. Choose Redirect as the action type.
  3. Name your action. The name will update below in real time.
  4. Choose an appropriate icon to give users a quick reference.
  5. Now we need to find the URL that this action will take users to. This will involve a little bit of URL hacking…

Step 5: In a new tab, open the Account Detail page (or the standard Salesforce version of whatever page you’re working on).

image4

Step 6: Problem: I’ve already overridden this page with a Skuid page.

image5

Solution: URL Hacking

  1. Go into the URL and tell the page exactly what you want to see: /{{Id}}?nooverride=1

(Your record Id will be different)

  1. Click Go.

For more instructions about returning to default layouts, see this section in the Visualforce override topic.

Step 7: Scroll all the way down to Notes & Attachments and click Attach File.

image6

Step 8: On the attach file page, go into the URL and start making it into a URL you can use for the Redirect URL on your page.

image7

  • Locate everything in the URL after force.com
  • In this example, the initial URL is /p/attach/NoteAttach?pid=001U000000OPtqi&parentname=Acme+Industrial &retURL=%2F001U000000OPtqiIAD
  • Replace the 15-digit Id with the template {{$Param.Id}}
  • Delete “parentname=xy+z”
  • Our finished URL template is: /p/attach/NoteAttach?pid={{$Param.id}}&retURL=%2F{{$Param.id}}

Step 9: Copy and paste the URL template into the URL field.

image8

The template {{$Param.id}} will pull in the Id parameter in the URL - which on this page is the Id of the Account record.

Step 10: Click Save, then click Preview

image9

Step 11: Choose the Account whose page you want to preview, then click Go.

image10

  1. Start typing the name of an Account and select it from the list that will appear by clicking on it.
  2. Click Go.

Moment of Truth: Test your upload button.

image11

Success! You’ll be redirected to the Attach File page for this Account record.

image12

Not seeing this page? Return to Step 7-8 and make sure you entered the correct URL /p/attach/NoteAttach?pid={{$Param.Id}}&retURL%2F{{$Param.Id}}