In this blog post, we’re going to look at how FormAssembly interacts with the new ‘Files’ introduced in Lightning. Previously, the ‘Attachments’ object worked within FormAssembly and Salesforce, but as we move forward fully into Lightning, we needed an update on working with the new ‘Files’ interface. Keep reading for a step-by-step explanation of how to execute this in your FormAssembly account.
Note: FormAssembly is also working on a built in solution to this, which will be available shortly. But until then, this tutorial will allow you to work with ‘Files’ accordingly. Also, Chatter must be enabled for this tutorial to work.
The form you use with file uploads can be as simple or as complex as you’d like. For our example, we’ll keep it pretty simple so that we can focus on the core value – files.
We’ll use a form that just has a field for ‘Account Name’ and then the ‘File’ we’d like to attach to that account:
Now that we have the forms set up, let’s have a look at which connectors we’re using.
Form Connector Setup
For the connector, we’ll look up the ‘Account’ by name and then upload the ‘File’ to that ‘Account.’
First, the straightforward ‘Account’ lookup:
We do this lookup solely to refer to it later and attach the ‘File’ accordingly.
Now, the fun part – the ‘File’ upload. The ‘Object’ structure of this was quite elusive, but we’ve got it nailed down to just one step, creating a ContentVersion:
Now, let’s have a closer look at these fields and what they relate to.
Version Data: This is the actual data for the ‘File,’ so we’ll map in the “File Upload” field from our form.
Path On Client: This is the internal Salesforce path, so again we’ll map the actual file data, in the “File Upload” field in our form.
First Publish Location ID: the ID of the object you want to associate the file to. In this case, we’re going to refer to the ‘Account’ we found in the first step of the connector, by using the “ID of an object above” and selecting “1. Account.”
Content Location: “S” – this lets Salesforce know that we’re uploading the file and not referring to it on an external system.
- For reference:
- ”S” = Within Salesforce
- “E” = External to Salesforce
Content Origin: “H” – we’re going to store the file actually in Salesforce and not an external system, so we’ll use the Chatter option. Note: Chatter must be enabled in your org.
- For reference:
- ”C” = Content from a Library (external)
- “H” = Chatter : Chatter must be enabled.
Note: when you choose the ContentVersion Object, two fields will appear, “Title” and “ContentDocument ID”.
- Do not map anything to the ContentDocument ID. This is created for you when you create a ContentVersion and mapping a value here will throw an error.
- Title you can optionally map if you want to rename the file.
View Salesforce Records
Now we’re ready to test and view our results in Salesforce. Let’s first run some data through the form:
And then have a look at that File in the Account:
And also confirm that we can see it in the Files tab:
And there we have it! Files uploaded through FormAssembly to the new ‘Files’ tab of Salesforce Lightning.
Want some more Salesforce use cases? Read our big guide to Salesforce forms with FormAssembly, or check out our FormAssembly + Salesforce eBook below. Don’t have a FormAssembly account? Sign up today!