Solved

Load Opportunity Attachments from SFDC to Gainsight

  • 28 July 2020
  • 8 replies
  • 495 views

Userlevel 7
Badge +11

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). 

icon

Best answer by jean.nairon 28 July 2020, 22:03

View original

8 replies

Badge

You should be able to generate a URL from the SFDC Attachment object, linking back to the Opps ID via the record Parent ID.

Userlevel 6
Badge +4

@mathieu.brillon is correct. You should create a field on the Opp or Account record to load the attachment url to it. Attachments have an ID just like any other record in SFDC and you can create a formula to create its URL. Here’s an article from SFDC Support that shows how to do this in Classic (the url should be different for Lightning): 

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.

 

 

Userlevel 7
Badge +11

Thanks guys! I’m going to try this out. 

Badge

Did it work out for you @gunjanm

Userlevel 7
Badge +11

@CurtisValentine still working on it; the initiative relating to this is lower priority. I will update here once done!

Userlevel 7
Badge +11

@jean.nairon @CurtisValentine FYI - I attempted this using Content Document object via Gainsight Rules Engine. I successfully loaded one URL - only because I specified the ContentDocument ID. It will not allow me to filter for First Publish Location ID (equivalent to Opportunity or Account ID) starts with 006, which would give me Opportunities. It also won’t let me filter for type = PDF. There are some nuances here, so I’ve started a support ticket.

I tried to create a formula field in SFDC SBX as suggested but could not look up the Attachment on the Opportunity. 

Userlevel 7
Badge +11

@jean.nairon @CurtisValentine FYI I have now solved this. I had to clone the Gainsight Special permission set and add the Query All Files permission in order to open up access to all files for me. I still cannot filter for starts with our Opportunity ID prefix, but this is now MUCH further than we ever were before. 

Userlevel 6
Badge +4

That’s awesome and a really good find with permissions issue. 

Reply