2

On lightning, I changed the File Settings and checked on this feature:

“Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments”

In my code, I have written a Javascript remote action that creates a case, inserts it, then it creates an attachment (with the above case's Id as parent id) and inserts it.

The issue is that I open the newly created case and there is no file there, only an attachment.

What am I missing?

N.B. assuming this cannot be achieved using the above settings, can I create a trigger to do the same?

  • Is there any reason you couldn't just change the code to create a file instead of attachments and then you don't have to mess with a trigger? – Kris Goncalves Dec 8 '19 at 16:44
2

I assume “Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments” is about standard way to upload attachments on the record page. On the other hand, you are inserting attachment in your custom logic. You need to insert files using ContentDocument, ContentVersion and ContentDocumentLink objects from now. Check the next article and take it as guidance.

| improve this answer | |
1

That setting only applies to the standard UI related list components, not to any custom code you've written. If your code creates an old Attachment object, that is what will be created. You will need to refactor your code to create a ContentVersion record.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.