Tell me more ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

So I was wondering how I can attach a file to an account. Basically what we do is sell a product online that requires an agreement. When they buy the product, we generate a pdf of the agreement and mail it to them. What I would like to do is upload the pdf agreement and attach it to the corresponding opportunity or account. I am pretty sure this can be accomplished, but I don't see much documentation on it. I am using php and the API to create everything. Any one have any ideas?

share|improve this question

2 Answers

up vote 1 down vote accepted

You can just create an Attachment on the Account. It should work the same way as creating an object in Salesforce.

Some important considerations:

  • The API sends and receives the binary file attachment data encoded as a base64Binary data type. Prior to creating a record, client applications must encode the binary attachment data as base64. Upon receiving a response, client applications must decode the base64 data to binary (this conversion is usually handled for you by the SOAP client).

  • The create call restricts these files to a maximum size of 5 MB. For a file attached to a Solution, the limit is 1.5MB. The maximum email attachment size is 3 MB.

share|improve this answer
This worked perfectly for what I was trying to achieve. Thanks for the advice! – jeffro25 Feb 6 at 15:26

I would recommend using chatter files related to the record rather than attachments as chatter files have a number of features that attachments lack.

To upload a file and relate it to a record you use a feeditem with the following required fields.

ContentData: base64 encoded file
ContentFileName: file name
ParentId: account/opportunity ID
Type: 'ContentPost'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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