Difference in Static Resource, Documents and Attachments in Salesforce

Static resource:

  1. Static resources allow you to upload content that you can reference in a Visualforce page, including archives (such as .zip and .jar files), images, stylesheets, JavaScript, and other files.
  2. Using a static resource is preferable to uploading a file to the Documents tab because you can package a collection of related files into a directory hierarchy and upload that hierarchy as a .zip or .jar archive.
  3. You can reference a static resource by name in page markup by using the $Resource global variable instead of hard coding document IDs.
  4. In addition, using static resources to refer to JavaScript or cascading style sheets (CSS) is preferable to including the markup inline. Managing this kind of content using static resources allows you to have a consistent look and feel for all your pages and a shared set of JavaScript functionality.
  5. A single static resource can be up to 5 MB in size, and an organization can have up to 250 MB of static resources, total.

Document:

  1. Represents a file that a user has uploaded. Unlike Attachment records, documents are not attached to a parent object.
  2. Supported Calls:create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), undelete(), update(), upsert()
  3. You must have the “Edit” permission on documents and the appropriate access to the Folder that contains a document in order to create or update a document in that Folder.
  4. When creating or updating a document, you can specify a value in either the Body or Url fields, but not both.
  5. The API sends and receives the binary file data encoded as a base64 data type. Prior to creating a record, clients must encode the binary file data as base64. Upon receiving an API response, clients must decode the base64 data to binary (this conversion is usually handled for you by the SOAP client).
  6. You can only create or update documents to a maximum size of 5 MB.
  7. Store Web resources, such as, logos, DOT files, and other Visualforce materials in folders without attaching them to records.

Attachments:

  1. Attach files to records from the Attachments related list on selected detail pages.
  2. Represents a file that a User has uploaded and attached to a parent object.
  3. Supported Callscreate(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), undelete(), update(), upsert()
  4. 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.
  5. 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.
  6. Attachment records are not searched during text searches. (When issued by an administrator, the query results include Attachment records from the Recycle Bin. Whereas 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:
  7. All of the fields are accessible using the describeSObjects() and query() calls. However, you can't receive the Body field for multiple records in a single query() call. If your query returns the Body field, your client application must ensure that only one row with one Attachment is returned; otherwise, an error occurs. A more effective approach is to return IDs (but not Attachment records in the Body field) from a query() call and then pass them into retrieve() calls that return the Body field.

Comments

Popular posts from this blog

List of Key Prefixes in Salesforce

SFDX Install CPQ in Scratch org