Newer Version Available

This content describes an older version of this product. View Latest

Resource File for Apex

Marks a record with a custom error message and prevents any DML operation from occurring.

The error message to mark the record with.

When used on Trigger.new in before insert and before update triggers, and on Trigger.old in before delete triggers, the error message is displayed in the application interface.

This method escapes any HTML markup in the specified error message. The escaped characters are: \n, <, >, &, ", \, \u2028, \u2029, and \u00a9. This results in the HTML markup not being rendered; instead it is displayed as text in the Salesforce user interface.

Note

When used in Visualforce controllers, the generated message is added to the collection of errors for the page. For more information, see Validation Rules and Standard Controllers in the Visualforce Developer's Guide.

Marks a record with a custom error message, specifies whether or not the error message should be escaped, and prevents any DML operation from occurring.

Indicates whether any HTML markup in the custom error message should be escaped (true) or not (false).

Be cautious if you specify false for the escape argument. Unescaped strings displayed in the Salesforce user interface can represent a vulnerability in the system because these strings might contain harmful code. If you want to include HTML markup in the error message, call this method with a false escape argument and make sure you escape any dynamic content, such as input field values.

An Exception object or a custom exception object that contains the error message to mark the record with.

Valid values for algorithmName are:
  • AES128
  • AES192
  • AES256
These are all industry standard Advanced Encryption Standard (AES) algorithms with different size keys. They use cipher block chaining (CBC) and PKCS5 padding.
All email must have a recipient value of at least one of the following:
  • toAddresses
  • ccAddresses
  • bccAddresses
  • targetObjectId
  • targetObjectIds
Please note that the following headers aren't allowed:
  • cookie
  • set-cookie
  • set-cookie2
  • content-length
  • authorization
If any of these are used, an Apex exception will be thrown.

If the BCC compliance option is set at the organization ​level, the user cannot add BCC addresses on standard messages. The following error code is returned: BCC_NOT_ALLOWED_IF_BCC_ COMPLIANCE_​ENABLED. ​Contact your salesforce.com representative for information on BCC compliance.

If no custom setting data is defined for the user, this method returns a new custom setting object. The new custom setting object contains an ID set to null and merged fields from higher in the hierarchy. You can add this new custom setting record for the user by using insert or upsert. If no custom setting data is defined in the hierarchy, the returned custom setting has empty fields, except for the SetupOwnerId field which contains the user ID.

If the transaction would cause the organization to exceed its daily email limit, using this method results in the following error: System.HandledException: The daily limit for the org would be exceeded by this request.

If the organization doesn’t have permission to send API or mass email, using this method results in the following error: System.NoAccessException: The organization is not permitted to send email.

Valid log levels are (listed from lowest to highest):
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

The JSON content to deserialize.

The Apex type of the object that this method creates after deserializing the JSON content.

Deserializes the specified JSON string into an Apex object of the specified type.

The optional opt_allOrNone parameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

The optional opt_DMLOptions parameter specifies additional data for the transaction, such as assignment rule information or rollback behavior when errors occur during record insertions.

Set to false to return any errors encountered in this operation as part of the returned result. If set to true, this method throws an exception if the operation fails. The default is true.

For Apex saved using Salesforce.com API version 21.0 or earlier, this method returns the custom setting data set record with fields merged from field values defined at the lowest hierarchy level, starting with the user. Also, if no custom setting data is defined in the hierarchy, this method returns null.

Note

  • After an sObject is deleted using this method it cannot be undeleted.
  • Only 10,000 sObjects can be specified for deletion.
  • The logged-in user can delete any sObject that he or she can query in their Recycle Bin, or the recycle bins of any subordinates. If the logged-in user has “Modify All Data” permission, he or she can query and delete sObjects from any Recycle Bin in the organization.
  • Do not include an sObject that was deleted due to a cascade delete; otherwise an error occurs. For example, if an account is deleted, all related contacts, opportunities, contracts, and so on are also deleted. Only include sObjects of the top level account. All related sObjects are automatically removed.
  • Deleted items are added to the number of items processed by a DML statement, and the method call is added to the total number of DML statements issued. Each executed emptyRecycleBin method counts against the governor limit for DML statements.

The returned date is in the GMT time zone.

If the JSON content to parse contains attributes not present in the Apex type specified in the argument, such as a missing field or object, this method ignores these attributes and parses the rest of the JSON content. However, for Apex saved using Salesforce.com API version 24.0 or earlier, this method throws a run-time exception for missing attributes.

Log levels are cumulative. For example, if the lowest level, ERROR, is specified for Apex Code, only debug methods with the log level of ERROR are logged. If the next level, WARN, is specified, the debug log contains debug methods specified as either ERROR or WARN.

You can't use getQueryLocator with any query that contains an aggregate function.

This method is only valid when a site is associated with a Customer Portal, and when the user license for the default new user profile is a high-volume portal user.

Note

The External_ID_Field is of type Schema.SObjectField, that is, a field token. Find the token for the field by using the fields special method. For example, Schema.SObjectField f = Account.Fields.MyExternalId.

The length of privateKey must match the specified algorithm: 128 bits, 192 bits, or 256 bits, which is 16, 24, or 32 bytes, respectively. You can use a third-party application or the generateAesKey method to generate this key for you.

This method can be called when you know in advance how many addresses emails will be sent to as a result of the transaction.

  • Cookie names and values set in Apex are URL encoded, that is, characters such as @ are replaced with a percent sign and their hexadecimal representation.
  • The setCookies method adds the prefix “apex__” to the cookie names.
  • Setting a cookie's value to null sends a cookie with an empty string value instead of setting an expired attribute.
  • After you create a cookie, the properties of the cookie can't be changed.
  • Be careful when storing sensitive information in cookies. Pages are cached regardless of a cookie value. If you use a cookie value to generate dynamic content, you should disable page caching. For more information, see “Caching Force.com Sites Pages” in the Salesforce online help.

Important

You must specify a value for setTemplateId, setHtmlBody, or setPlainTextBody. Or, you can define both setHtmlBody and setPlainTextBody.

If the JSON content to parse contains attributes not present in the Apex type specified in the argument, such as a missing field or object, this method throws a run-time exception.

If the key is a string, the key value is case-sensitive.

Valid values include:
  • Theme1
  • Theme2
  • Theme3
  • Theme4
  • PortalDefault
  • Webstore