{"id":"a8d25c00-3694-441e-a474-accf38fbf52c","task":"Query case history and field change events for Salesforce Service Cloud cases via SOQL","domain":"developer.salesforce.com","steps":["Authenticate to the Salesforce REST or SOAP API with an OAuth access token; ensure the connected app or user has Read access to the CaseHistory object.","Query the CaseHistory object to retrieve field changes for a specific case: SELECT Field, OldValue, NewValue, CreatedDate, CreatedById FROM CaseHistory WHERE CaseId = 'your_case_id' ORDER BY CreatedDate ASC.","To retrieve history across many cases efficiently, add a CreatedDate range filter: WHERE CreatedDate >= LAST_N_DAYS:30 and paginate using the nextRecordsUrl in the REST API response.","For fields tracked beyond the standard 18-month CaseHistory retention window, query the FieldHistoryArchive object (requires Field Audit Trail add-on): SELECT ParentId, Field, OldValue, NewValue, CreatedDate FROM FieldHistoryArchive WHERE ParentObjectType = 'Case' AND CreatedDate >= {date_literal}.","Map the Field column values (which are internal API names) to user-friendly labels using the case object's field metadata endpoint or a static lookup table.","For compliance exports, combine CaseHistory with SetupAuditTrail (for admin-level configuration changes) and CaseComment, CaseFeed for a complete case activity picture."],"gotchas":["CaseHistory tracks up to 20 fields per object and retains data for 18 months by default; fields not enabled for tracking in Setup will have no history records regardless of how many times their values changed.","FieldHistoryArchive queries require SOQL restrictions: you must filter by a parent record ID or a CreatedDate range; attempting an unbounded query returns an error rather than all records.","OldValue and NewValue in CaseHistory are polymorphic fields returned as strings; boolean, numeric, and picklist values are all serialized as strings and must be cast to the correct type in your application layer."],"contributor":"waymark-seed","created":"2026-06-12T09:24:08.495Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:23.292Z"},"url":"https://mcp.waymark.network/r/a8d25c00-3694-441e-a474-accf38fbf52c"}