Check if the Current Org Is a Sandbox or Production
SELECT Id, IsSandbox FROM Organization LIMIT 1Query All Fields, Custom Fields, or Standard Fields
- FIELDS(ALL)—to select all the fields of an object.
- FIELDS(CUSTOM)—to select all the custom fields of an object.
- FIELDS(STANDARD)—to select all the standard fields of an object.
In each case, FIELDS() respects field-level security so it only shows the fields that you have permission to access.
SELECT FIELDS(ALL) FROM Account LIMIT 200
SELECT FIELDS(CUSTOM) FROM Account LIMIT 200
SELECT FIELDS(STANDARD) FROM Account
You can also mix FIELDS() with other field names in the field list. For example:
SELECT Name, Id, FIELDS(CUSTOM) FROM Account LIMIT 200
SELECT someCustomField__c, FIELDS(STANDARD) FROM AccountSimple SOSL
FIND {Test*} IN ALL FIELDS RETURNING Account(Id), Contact(Id), Lead(Id)Query Records from Recently Viewed List View in Salesforce
SELECT Id, Name FROM RecentlyViewed WHERE Type ='Account'Query with Date Formats and Date Literals (e.g., WHERE CreatedDate = YESTERDAY) in SOQL
SELECT Id FROM Account WHERE CreatedDate = YESTERDAY
SELECT Id FROM Opportunity WHERE CloseDate > LAST_MONTHReference Link: Date Formats and Date Literals in WHERE
Get the Standard System Administrator Profile / Permission Set
SELECT Profile.Name FROM PermissionSet WHERE IsCustom = FALSE AND Profile.UserType = 'Standard' AND Profile.PermissionsAuthorApex = TRUEGet the URL Prefix of a Site
SELECT Id, Name, UrlPathPrefix, Status FROM Network Query Fields Excluding Certain Strings
e.g. Get the List of Users whose emails still with invalid suffix after sandbox refresh or creation
SELECT Id, Name, Email, UserRole.Name FROM User WHERE IsActive = TRUE AND (NOT Email LIKE '%invalid')Query Multi-Picklist Values Using INCLUDES in SOQL
SELECT Id, Name, Email, UserRole.Name FROM User WHERE thelist__c includes ('ABC','XYZ')