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

Preserve Audit Fields (Created By, Updated By) #6

Closed douglascayers closed 7 years ago

douglascayers commented 8 years ago

Reported by Rick MacGuigan

The current way the notes and attachments are converted to chatter notes and files is pure apex, not the api, so the audit fields cannot be set even if the permission is granted to the current user running the conversion code.

Need to investigate if using REST API via callouts from the batchable apex will allow for the conversion to occur and preserve the audit fields.

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/

https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/intro_input.htm#cc_upload_binary_files

https://developer.salesforce.com/docs/atlas.en-us.202.0.api.meta/api/

douglascayers commented 7 years ago

I recently spoke with Henry Liu, Product Manager for Notes, and this seems to simply be a limitation of the API. His and other teams are working to close the gap but no ETA as of now.

douglascayers commented 7 years ago

This is now possible at least with ContentVersion records when converting Attachments to Files. I will be updating the code base soon to reflect this capability.

douglascayers commented 7 years ago

Fixed is latest major update https://github.com/DouglasCAyers/sfdc-convert-attachments-to-chatter-files/commit/0da26d8624c1c1d546454b190de5c2d71e0d1d90