Hi folks, has anyone ever brought in Opportunity attachments (specifically PDF contracts) into Gainsight for CSMs to easily reference? The object I have narrowed it down to in SFDC is Attached Content Document; however, the Rules Engine a) does not actually let me query anything on it, and b) shows only Account and Customer Info as lookup objects, even though the attachments actually sit on the Opportunity.
I’d like this to either easily live on the Opportunity related list as a link to download the PDF or create a separate related list with all attachments from SFDC (narrowing down by Type would be nice but can be dealt with).
Best answer by jean.nairon
The example URL they used is: https://na1.salesforce.com/servlet/servlet.FileDownload?file=015300000000xvU
The ID in this case would be: 015300000000xvU
Here’s some additional details on how to create the url. The main thing you may want to do is ensure you grab the right url for the right document.
When requested from a valid session (i.e. after someone has logged in to salesforce) this URL (that includes the ID of the attachment) works:
/servlet/servlet.FileDownload?file=00PM0000001fH6h
If you create a text formula field on an object of this form:
HYPERLINK('/servlet/servlet.FileDownload?file=' + AttachmentId__c, 'View', '_blank')
the link can be displayed in default (layout based) UI. You will have to use an Attachment after trigger to store the AttachmentId on the object. The Attachment's ParentId tells you what its immediate parent object is and you can query as needed from there to find the object if it is not the immediate parent. (You need to decide what you want to do when there are multiple Attachments.)
But if you want to say email the link to a user that is not logged in to salesforce, you will need to use an "externally available" Document not an Attachment (though you could copy the Attachment content to a Document automatically in a trigger). Details on how to do this are provided in this blog post Salesforce: How to make a Document public?. This mechanism works for e.g. PDF as well as images.