How to attach documents in FormAssembly as Files in Salesforce Lightning
As Salesforce is phasing out Notes and Attachments, when you want to send document attachments from Form Assembly into Salesforce these need to go into Files. There is a useful FormAssembly help article but I found I needed a bit more research to get this working so thought you may find this blog useful.
1. Add Contact, Account (and Opportunity) as normal in FormAssembly – see our Top 10 FormAssembly tips if you need help with this
2. Next choose ‘Add an Object Dependent on [the object where you’d like the file to sit]’ – in my case that was ‘Add an Object Dependent on Opportunity’
3. Choose Create and then ‘Content Version’
4. At this point, there is a confusing step – you need to delete the mapping of one of the ‘required’ fields called ContentDocumentID. If you have that field in you will receive an error that looks something like “Create ContentVersion – ContentDocument ID: id value of incorrect type: [document name]”. Once the ContentDocumentID section in the Connector is deleted, and you have the settings below, everything will work perfectly.
5. In the Relationship section choose First Publish Location ID
6. For Version Data and Path on Client choose the document – you get this field from ‘a field in your form’ and scroll to where your document is
7. Content Origin should be a Formula set to “H” (this means the file is stored as a Chatter post, see Form Assembly’s help article)
8. Content Location should be a formula set to “S” (this means the file is stored in Salesforce not as an External document)
9. Optionally you can have the field called Title which you can set to something other than the file name (you can leave this mapping out if you’re happy for the file to have the same name in Salesforce as the name of the file the person submits). I used a formula with the created date, first name, last name and what the document should be (e.g. Script / Covering Letter). N.B. If you use a formula for the Title field and no file is uploaded, you may receive an error. If the file upload is not a required field in FormAssembly, use a skip-if formula to skip the ContentVersion step if the file upload field is empty.
10. The final result looks good in Salesforce – here’s two example files held on an Opportunity
I hope this post has helped you, let me know if you have any tips to share on using Files in FormAssembly to integrate with Salesforce.