Tuesday, October 8, 2019

Deleting Debug logs

If you have had to take over a system with little to KT and you have been running debug logs then you can attest to the pain points of deleting the logs by clicking Delete All..

There is a way out using Tooling API.

Delete logs are found from workBench using the following query

SELECT Id, StartTime, LogUserId, LogLength, Location FROM ApexLog

  1. Open Developer Console.
  2. At the bottom of the console, select the Query Editor tab.
  3. Select Use Tooling API.
  4. Enter this SOQL query:
    SELECT Id, StartTime, LogUserId, LogLength, Location FROM ApexLog
  5. Click Execute.
  6. Select the logs you want to delete. To sort by a column, click its header. To select individual logs, press Ctrl (Windows or Linux) or Command (macOS). To select a block of logs, press Shift.

Query to find fields being History tracked in Salesforce

Use the following query to find fields being history tracked

SELECT QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Account' AND IsFieldHistoryTracked = true

You could always put this in a loop and get list of fields tracked for all objects