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

Skip Empty Size Attachments #44

Open umeditor opened 6 years ago

umeditor commented 6 years ago

While running the conversion in my full sandbox using version 1.3 of the code, I'm getting a number of errors logs saying "Required fields are missing: [VersionData] Required fields are missing: [VersionData]". I see in issue #25 that it might be related to a required field or validation but I can't figure out where to look for it. Any suggestions?

douglascayers commented 6 years ago

Hi @umeditor,

Good researching. In this case VersionData is standard field that holds the binary content of the attachment/file.

If you can narrow down to the specific Attachment(s) that are failing I would like to know more details about them. For example, does your org have Attachments whose BodyLength field value is zero? If yes what kind of attachment is that?

Thanks,

Doug

umeditor commented 6 years ago

All of these attachments are zero length. My best guess is they were created by an automated process, maybe an external form that didn't work. Using dataloader.io to export the associated attachment records, I see they all have:

douglascayers commented 6 years ago

Thanks for the follow up. Unless you see any value in those zero size attachments, for now you can export then delete them then try the conversion again.

Also recommend upgrading to latest version of the app which now supports private attachments to remain private files shared to the parent record.

Since Files can’t be empty size then all I can do in the code is skip those attachments or set their body to be same as their title. Thoughts on the approach skip or re-create with body same as title?

umeditor commented 6 years ago

Deleting the zero length files resolved all the errors. I'd be inclined to skip such files with a useful message explaining why. FWIW, I'm already running version 1.3, which I believe is current.

douglascayers commented 6 years ago

Thanks for the follow up. I think skipping them and logging why is good approach too. Glad you got it working after deleting the zero length attachments.