You need to sign in to do that
Don't have an account?
Brian C
Transitioning from Attachments to Files
I am working on transitioning my org's workflow from using Attachments to Files in order to be compatibile with Lightning. I have a specific use case I need guidance on:
In Classic, we have a work process in which an artist uploads an image file to a custom object record. This file is automatically renamed via an Apex controller to a standardized filename. We have a separate Visualforce page using the custom object as its standard controller (also using a custom Apex extension). The Visualforce page renders the image for printing (along with other related data from the record) by referencing the generic file name.
For Lightning, I have built a Lightning component for file upload. This component uploads the image as a File/ ContentDocument associated with the custom object. How can I replicate similar functionality for the Visualforce page with Salesforce Files? My initial thought was to add a field to the custom object to store a URL for viewing the File, but I'm not sure how to generate such a URL.
In Classic, we have a work process in which an artist uploads an image file to a custom object record. This file is automatically renamed via an Apex controller to a standardized filename. We have a separate Visualforce page using the custom object as its standard controller (also using a custom Apex extension). The Visualforce page renders the image for printing (along with other related data from the record) by referencing the generic file name.
For Lightning, I have built a Lightning component for file upload. This component uploads the image as a File/ ContentDocument associated with the custom object. How can I replicate similar functionality for the Visualforce page with Salesforce Files? My initial thought was to add a field to the custom object to store a URL for viewing the File, but I'm not sure how to generate such a URL.
Using the ContentVersion.Id and ContentVersion.ContentBodyId, I created a url pointing to baseUrl + '/sfc/servlet.shepherd/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId='+ContentVersion.Id+'&contentId='+ContentVersion.contentbodyid'. I then wrote that to a URL field on the custom object.
Seems to be working well.