Attachment

Represents a file that a User has uploaded and attached to a parent object.

Supported Calls

create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), undelete(), update(), upsert()

Fields

Field Details
Body
Type
base64
Properties
Create, Update
Description
Required. Encoded file data.
BodyLength
Type
int
Properties
Filter, Group, Nillable, Sort
Description
Size of the file (in bytes).
ConnectionReceivedId
Type
reference
Properties
Filter, Nillable
Description
ID of the PartnerNetworkConnection that shared this record with your organization. This field is available if you enabled Salesforce to Salesforce.
ConnectionSentId
Type
reference
Properties
Filter, Nillable
Description
ID of the PartnerNetworkConnection that you shared this record with. This field is available if you enabled Salesforce to Salesforce. This field is supported using API versions earlier than 15.0. In all other API versions, this field’s value is null. You can use the new PartnerNetworkRecordConnection object to forward records to connections.
ContentType
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
The content type of the attachment.

If the Don't allow HTML uploads as attachments or document records security setting is enabled for your organization, you cannot upload files with the following file extensions: .htm, .html, .htt, .htx, .mhtm, .mhtml, .shtm, .shtml, .acgi, .svg.

Description
Type
textarea
Properties
Create, Filter, Nillable, Sort, Update
Description
Description of the attachment. Maximum size is 500 characters. This field is available in API version 18.0 and later.
IsEncrypted
Note

Note

This information is about Shield Platform Encryption and not Classic Encryption.

Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Indicates whether the attachment is encrypted using Shield Platform Encryption (true) or not (false). This field is available in API version 34.0 and later.
IsPartnerShared
Type
boolean
Properties
Defaulted on create, Filter, Update
Description
Indicates whether this record is shared with a connection using Salesforce to Salesforce. Label is Is Shared With Partner.
IsPrivate
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
Indicates whether this record is viewable only by the owner and administrators (true) or viewable by all otherwise-allowed users (false). During a create or update call, it is possible to mark an Attachment record as private even if you are not the owner. This can result in a situation in which you can no longer access the record that you just inserted or updated. Label is Private.

Attachments on tasks or events can't be marked private.

Name
Type
string
Properties
Create, Filter, Group, Sort, Update
Description
Required. Name of the attached file. Maximum size is 255 characters. Label is File Name.
OwnerId
Type
reference
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
ID of the User who owns the attachment. This field was required previous to release 9.0. Beginning with release 9.0, it can be null on create.

The owner of an attachment on a task or event must be the same as the owner of the task or event.

ParentId
Type
reference
Properties
Create, Filter, Group, Sort
Description
Required. ID of the parent object of the attachment. The following objects are supported as parents of attachments:
  • Account
  • Asset
  • Campaign
  • Case
  • Contact
  • Contract
  • Custom objects
  • EmailMessage
  • EmailTemplate
  • Event
  • Lead
  • Opportunity
  • Product2
  • Solution
  • Task
Note

Note

If you are importing Attachment data and need to set the value for an audit field, such as CreatedDate, contact Salesforce. For example, for compliance reasons, you may prefer to set the CreatedDate to the date the record was originally created in your system, rather than the date it was imported into Salesforce. Audit fields are automatically updated during API operations unless you request to set these fields yourself.

Usage

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 25 MB. For a file attached to a Solution, the limit is 1.5 MB. The maximum email attachment size is 3 MB.

The API supports attachments on email in create, delete, or update calls. The query call does not return attachments parented by email, unless the user performing the query has the “Modify All Data” permission.

Note

Note

  • Attachment records are not searched during text searches.
  • When issued by an administrator, the query results include Attachment records from the Recycle Bin.
  • When issued by a non-administrator, the queryAll() call results do not include Attachment records from the Recycle Bin.

Access to fields depends on the method being used:

See Also