開発者は、カスタムプロファイルに割り当てられたユーザーがシステム監査機能を実装する必要があります。 「監査人」は、アカウントオブジェクトの履歴レコードに対して検索を実行します。開発者は、検索によって6か月から12か月前の履歴レコードが返されるようにする必要があります。以下のコードでは、アカウント履歴レコードを取得するためにどのSELECT文を挿入すればよいでしょうか?4445 Java Date initialDate = System.Today().addMonths(-12); Date endDate = System.Today().addMonths(-6); // ここにSELECT文を挿入します
正解:C
To query history records for a standard object like Account, the developer must use the correct API name, which is AccountHistory (not Account_History). When filtering for a range of dates, SOQL provides the BETWEEN operator, which makes the query cleaner and more readable. Option C uses both the correct object name and the BETWEEN syntax, making it the most efficient solution. In SOQL, CreatedDate BETWEEN :initialDate AND :endDate is shorthand for CreatedDate >= :initialDate AND CreatedDate <= :endDate. In the provided code, initialDate is 12 months ago (the older date) and endDate is 6 months ago (the more recent date). Therefore, the range correctly captures records between those two timestamps. Option A and B use an incorrect object name (Account_History). Option D uses the incorrect comparison operator => (the correct operator is >=). Furthermore, Option C follows the best practice for date range queries in Apex by using bind variables with the standard AccountHistory object, ensuring the "Auditors" profile can retrieve the necessary historical data within the platform's audit and security constraints.