Trace Flags
Inspect active debug trace flags (Tooling API).
SELECT Id, TracedEntityId, TracedEntity.Name, LogType,
StartDate, ExpirationDate, CreatedDate,
CreatedById, CreatedBy.Name,
ApexCode, ApexProfiling, Callout, Database,
System, Validation, Visualforce, Workflow
FROM TraceFlag
ORDER BY ExpirationDate DESC
Apex Logs (Basic)
Review recent Apex executions.
SELECT Id, Status, StartTime, LogUser.Name, Operation
FROM ApexLog
ORDER BY StartTime DESC
sf hardis:org:purge:apexlog --target-org myOrg
Apex Logs (Detailed)
Performance and execution context.
SELECT Id, LogUserId, LogUser.Name, LogLength,
DurationMilliseconds, Operation,
Status, StartTime, Location
FROM ApexLog
ORDER BY StartTime DESC
User Permission Sets
Non-profile permission sets for a user.
SELECT Id, PermissionSetId, PermissionSet.Name,
AssigneeId, Assignee.UserName, IsActive
FROM PermissionSetAssignment
WHERE Assignee.UserName = :username
AND PermissionSet.IsOwnedByProfile = FALSE
Contact Center Roles
Agent, Supervisor, Admin permission sets.
SELECT AssigneeId, Assignee.Email,
PermissionSetId, PermissionSet.Name
FROM PermissionSetAssignment
WHERE PermissionSet.Name IN (
'ContactCenterAgentExternalTelephony',
'ContactCenterSupervisorExternalTelephony',
'ContactCenterAdminExternalTelephony'
)
ORDER BY AssigneeId
Field-Level Security
Field access via profiles and permission sets.
SELECT Id, PermissionsRead, PermissionsEdit,
SobjectType, Field,
Parent.Type, Parent.Name,
Parent.PermissionSetGroup.DeveloperName,
Parent.Profile.Name
FROM FieldPermissions
WHERE Field = 'Object__c.Field__c'
Outgoing Emails Today
SELECT Id, Subject, EmailTemplateId,
FromAddress, ToAddress,
ParentId, Status
FROM EmailMessage
WHERE MessageDate >= TODAY
AND Incoming = FALSE
Email Volume by Year
SELECT CALENDAR_YEAR(CreatedDate), COUNT(Id)
FROM EmailMessage
GROUP BY CALENDAR_YEAR(CreatedDate)
Task Volume by Year
SELECT CALENDAR_YEAR(CreatedDate), COUNT(Id)
FROM Task
GROUP BY CALENDAR_YEAR(CreatedDate)
Active Users with Call Center
SELECT Id, UserName, CallCenterId
FROM User
WHERE IsActive = true
AND CallCenterId != NULL
Call Center Config
SELECT Id, Name, CustomSettings
FROM CallCenter
WHERE Id = '04vVC0000009WBxYAM'
Softphone Settings (JSON)
reqCallCenterType can be SCVBYOT, SCVOOTBTelephony, ...
{
"reqTimeout":"5000",
"reqStandbyUrl":"https://domain:port/softphone",
"reqCallCenterType":"SCVBYOT",
"reqSoftphoneHeight":"300",
"reqUseApi":"true",
"reqSoftphoneWidth":"500",
"reqSalesforceCompatibilityMode":"Lightning"
}
Flow Interviews
SELECT Id, Name, CurrentElement,
InterviewLabel, InterviewStatus, Error
FROM FlowInterview
ORDER BY InterviewLabel
sf hardis:org:purge:flow --target-org myOrg --delete-flow-interviews
Flow Versions and Durable IDs
DurableId is the Id to delete.
SELECT Id, FlowDefinitionView.ApiName,
VersionNumber, Status, Label, DurableId
FROM FlowVersionView
WHERE FlowDefinitionView.ApiName LIKE '%flow%'
AND VersionNumber < 60
ORDER BY VersionNumber DESC
Tooling API Flow Delete
DELETE /services/data/v58.0/tooling/sobjects/Flow/301Dy000000N9VWIA0
Custom Field IDs
SELECT Id, DeveloperName
FROM CustomField
WHERE EntityDefinition.QualifiedApiName = 'Account'
Metadata Dependencies
SELECT MetadataComponentType, MetadataComponentName,
RefMetadataComponentName, RefMetadataComponentId
FROM MetadataComponentDependency
WHERE RefMetadataComponentId IN (
'00Nfj00001vt9qvEAA',
'00Nfj000022m2N7EAI'
)
ORDER BY RefMetadataComponentName
sf hardis:doc:fieldusage --target-org myOrg --sObjects CustomObject__c
Apex Classes by Size
Find the largest classes to target for refactoring or splitting.
SELECT Name, LengthWithoutComments
FROM ApexClass
ORDER BY LengthWithoutComments DESC
Largest Files
SELECT Id, Title, ParentId,
Description, ContentSize, FileType
FROM ContentDocument
ORDER BY ContentSize DESC
LIMIT 50
Files Linked to Record
SELECT Id, ContentDocumentId, LinkedEntityId,
ShareType, Visibility
FROM ContentDocumentLink
WHERE LinkedEntityId = 'a0S1F000001AO96UAG'
Public File Links
SELECT Id, Name, DistributionPublicUrl,
ContentVersionId, ContentVersion.Title,
ContentDocumentId
FROM ContentDistribution
WHERE ContentDocumentId = '0691F000000GfYPQA0'
Agent Work by Service Channel
Purpose: Resolve error "This service channel is referenced elsewhere in Salesforce. Agent Work" (delete these rows).
SELECT Id, Name, PendingServiceRoutingId,
RoutingModel, RoutingPriority,
RoutingType, ServiceChannelId
FROM AgentWork
WHERE ServiceChannelId = '0N9590000004CIK'
Setup Audit Trail as CSV
sfdx force:data:soql:query -q "
SELECT Id, Action, Section, CreatedDate,
CreatedBy.Name, Display
FROM SetupAuditTrail
ORDER BY CreatedDate DESC
" --resultformat csv > _SetupAuditTrail.csv
sf hardis:org:diagnose:audittrail
Recent Login History
Spot unusual login sources or statuses in the past week.
SELECT Id, CreatedDate, UserId, User.Name,
LoginType, SourceIp, Status,
LoginGeo.City, LoginGeo.Country
FROM LoginHistory
WHERE CreatedDate = LAST_N_DAYS:7
ORDER BY CreatedDate DESC
LIMIT 200