douglascayers / sfdc-convert-attachments-to-chatter-files

📎 Easily migrate your Attachments to Salesforce Files.
https://douglascayers.com/2015/10/10/salesforce-convert-attachments-to-chatter-files/
BSD 3-Clause "New" or "Revised" License
73 stars 29 forks source link

Trigger question #45

Closed DarylMoon closed 6 years ago

DarylMoon commented 6 years ago

Doug this is a question not a bug report. How does the Attachment Trigger function compare with the Salesforce Files setting "Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments". Do they both do the same thing? Should we only use one or the other? We intend to also enable the background job in your App to catch any attachments that miss the automatic conversion (or for old documents).

douglascayers commented 6 years ago

Hi @DarylMoon,

Good question. They behave differently.

The Salesforce Files setting "Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments", ensures that documents the user uploads from the "Notes & Attachments" related list actually upload as a Salesforce File, not as an Attachment. This is a preventative measure that prevents the Attachment from ever being created and instead a File is created.

The Attachment Trigger that comes with my app is for when attachments do get created and you want them automatically converted into a File.

The reason for the trigger is for use case like you've already completed the migration but a third-party app used the API to insert an Attachment afterwards. The trigger will auto-convert that new attachment into a file without you running the migration process manually.

You can have both the Salesforce Files Setting and the Attachment Trigger enabled simultaneously; they do not collide with each other. If the Salesforce Files Setting is disabled but the Attachment Trigger is enabled then when the user uploads a document via "Notes & Attachments" related list then briefly that record exists as an Attachment and then the trigger converts it into a File. If you had the Salesforce Files Setting enabled then the upload process already ensures the document uploads as a File, not an Attachment, and so the trigger would not have been invoked.

Hope that clears it up, let me know if you have other questions.

Thanks,

Doug

DarylMoon commented 6 years ago

Thanks for your quick response Doug, that is perfect!