Custom Object File Field

customfieldslightning

I'm relatively new to Salesforce development. I have a requirement to create custom fields on our custom object; some of these fields must be able to hold a file attachment (PDFs usually).

I cannot seem to find any way to add a field where the user can upload a single file. The closest I can get is adding the Files related list in the lighting app builder, but this feels more like a work-around as its essentially just a bucket to hold all the files.

I haven't messed much with Apex Code but I'm sure theres a way to do it via code, I just need some help to be pointed in the right direction since I'm a little confused on how apex classes interact with objects and store data.

Thanks!

Best Answer

There is no such thing as a 'file field' in Salesforce. Files cannot be part of a record on a custom object. They can only be 'related' to a record. This is what you see when you add the Files related list to the page layout.

Judging from your description, you need the ability to upload files of a certain predefined type to a custom object record. This is not a standard ability of salesforce. It can be built using apex/lightning but that is not a beginner's project.

Maybe you are better off with a 3rd party app from the AppExchange. E.g. https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3u00000MRhurEAD seems enable you to do what you need.