No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Id Class
Namespace
Example: Getting an sObject Token From an ID
This sample shows how to use the getSObjectType method to obtain an sObject token from an ID. The updateOwner method in this sample accepts a list of IDs of the sObjects to update the ownerId field of. This list contains IDs of sObjects of the same type. The second parameter is the new owner ID. Note that since it is a future method, it doesn’t accept sObject types as parameters; this is why it accepts IDs of sObjects. This method gets the sObject token from the first ID in the list, then does a describe to obtain the object name and constructs a query dynamicallly. It then queries for all sObjects and updates their owner ID fields to the new owner ID.
Id Methods
The following are methods for Id.
addError(String)
Signature
public Void addError(String errorMsg)
Parameters
- errorMsg
- Type: String
The error message to mark the record with.
Return Value
Type: Void
Usage
This method is similar to the addError(String) sObject method.
Example
addError(String, Boolean)
Signature
public Void addError(String errorMsg, Boolean escape)
Parameters
Return Value
Type: Void
Usage
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.
Example
addError(Exception)
Signature
public Void addError(Exception exceptionError)
Parameters
- exceptionError
- Type: System.Exception
An Exception object or a custom exception object that contains the error message to mark the record with.
Return Value
Type: Void
Usage
This method is similar to the addError(Exception) sObject method.
Example
addError(Exception, Boolean)
Signature
public Void addError(Exception exceptionError, Boolean escape)
Parameters
- exceptionError
- Type: System.Exception
An Exception object or a custom exception object that contains the error message to mark the record with.
- escape
- Type: Boolean
Indicates whether any HTML markup in the custom error message should be escaped (true) or not (false).
Return Value
Type: Void
Usage
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.
Example
getSObjectType()
Signature
public Schema.SObjectType getSObjectType()
Return Value
Type: Schema.SObjectType
Usage
For more information about describes, see Understanding Apex Describe Information.