+ Start a Discussion
mscherflingmscherfling 

Sforce attachments to Custom Objects

When creating a custom tab with a custom object, I can add attachments to that custom object. However, the Sforce documentation appears not to support that same functionality. Is that true?

Thanks.
-- Mark
DevAngelDevAngel
what?
mscherflingmscherfling
Looking at the SForce documentation on attachments:

ParentId:
ID of the parent object of the Attachment. The following objects are supported as parents of Attachments:
Account
Campaign
Case
Contact
Contract
Opportunity
Product2
Solution

Yet, when I create a custom object and edit the layout, I can select Notes and Attachments for that custom object. I'd like to attach a file to my custom object from the API. Is that possible?
DevAngelDevAngel
Ok, sure. The key field to be concerned about is not on the custom object, but on the attachment object. In particular what you need to do is create an attachment object, set the various fields (body, name etc) and most importantly, set the parentId to the id of your custom object. This will relate the attachment to your object.

The documentation has omitted any reference to custom objects which is a bug in the documentation and we will address that.

Thanks for pointing this out.
mscherflingmscherfling
Thanks for the clarification.
RogerHandRogerHand


DevAngel wrote:

The documentation has omitted any reference to custom objects which is a bug in the documentation and we will address that.

Almost 4 years later and the bug is still in the version 9.0 documentation!
RogerHandRogerHand


RogerHand wrote:


DevAngel wrote:

The documentation has omitted any reference to custom objects which is a bug in the documentation and we will address that.

Almost 4 years later and the bug is still in the version 9.0 documentation!


Oops, sorry, just 1 year+ later.