Skip to content

SEL_OrgWideEmailAddress ​

Class · Group: Selectors

Learn it: Fast Start - Selectors and Selectors guide

apex
global inherited sharing class SEL_OrgWideEmailAddress extends SEL_Base

Extends: SEL_Base

Selector for the OrgWideEmailAddress SObject. Provides query methods for retrieving organization-wide email addresses configured in Salesforce.

Example

apex
List<OrgWideEmailAddress> addresses = new SEL_OrgWideEmailAddress().findByName(new Set<String>{'noreply@company.com'});
OrgWideEmailAddress randomAddress = (OrgWideEmailAddress)new SEL_OrgWideEmailAddress().getRandomItem();

See Also: SEL_Base


Methods ​

MethodDescription
global List<OrgWideEmailAddress> findByName(Set<String> addresses)Retrieves OrgWideEmailAddress records matching the provided email addresses.
global override List<SObjectField> getFields()Returns the core fields for OrgWideEmailAddress queries.
global override SObject getRandomItem()Retrieves a random OrgWideEmailAddress that is available to all profiles.

findByName ​

apex
global List<OrgWideEmailAddress> findByName(Set<String> addresses)

Retrieves OrgWideEmailAddress records matching the provided email addresses.

Parameters

ParameterTypeDescription
addressesSetA set of email addresses to search for

Returns OrgWideEmailAddress — List of matching OrgWideEmailAddress records

Example

apex
List<OrgWideEmailAddress> addresses = new SEL_OrgWideEmailAddress()
    .findByName(new Set<String>{'noreply@company.com'});

getFields ​

apex
global override List<SObjectField> getFields()

Returns the core fields for OrgWideEmailAddress queries.

Returns SObjectField — List of OrgWideEmailAddress SObjectField tokens

Example

apex
List<SObjectField> result = instance.getFields();

getRandomItem ​

apex
global override SObject getRandomItem()

Retrieves a random OrgWideEmailAddress that is available to all profiles.

Returns SObject — A random OrgWideEmailAddress available to all profiles, or null if none found

Example

apex
OrgWideEmailAddress randomEmail = new SEL_OrgWideEmailAddress().getRandomItem();

Constructors ​

ConstructorDescription
global SEL_OrgWideEmailAddress()Reads OrgWideEmailAddress records, the organisation-wide email addresses set up in the org.

SEL_OrgWideEmailAddress() ​

apex
global SEL_OrgWideEmailAddress()

Reads OrgWideEmailAddress records, the organisation-wide email addresses set up in the org. Every query skips the running user's object and field permission checks (system mode). Record sharing follows the class that calls the selector. Creating the selector runs no query.

Example

apex
SEL_OrgWideEmailAddress instance = new SEL_OrgWideEmailAddress();