cloudraysolutions.com

A recent system review with a client revealed a tedious and repetitive task.

The client’s org contains Files related to a Custom Object we will call “ObjectX”. These Files are XML format and therefore cannot be previewed directly in Salesforce. To view the File, a User needs to access Navigate to Files Related List>Click on the File Name>Select to Download the File>Save the File>Open File….5 steps to accomplish 1 task!

And so we began to think, how can we facilitate this process? The first solution that came to mind was to create a URL hack which would be a quick link on the ObjectX record to access the File. This would already save Users a step. Since there would only be 1 File per record, I didn’t need to worry about handling multiple Files.

I determined that we would need to use DLRS to help pull File data directly into the ObjectX record. Typically when using DLRS, the Rollup record directly references the Parent and Child Object. However, Files do not behave like your standard record with a direct relationship to the Object it is located on. A quick Google search led me to this thread where a contributor explained how to reference Files. Rather than directly referencing the ContentDocument (File) Object, I referenced the ContactDocumentLink which is the liaison between Files and the Record it is related to.

Once I did that, DLRS populated the File Id to a custom field “File__c” on the ObjectX record. Then, I did a little sleuthing (isn’t Salesforce all about detective work?!) and discovered that when I clicked the “Download” button on a File, a new browser tab opened containing a download URL.

I copied the URL to a Formula Text Field, replacing the Id with the “File_c” field on the ObjectX record (which contains the File Id).

I then used this field to create another Formula Text field which returned a URL. I did this in a 2 step process because the Hyperlink formula could not contain a record field.

And voila! Directly from the ObjectX record, a user can click on the File URL link and immediately save the file. A 5 step process automated to 2 steps!

Leave a Reply

Your email address will not be published. Required fields are marked *