A developer is writing a Visualforce page that queries accounts in the system and presents a data table with the results. The users want to be able to filter the results based on up to five fields. However, the users want to pick the five fields to use as filter fields when they run the page. Which Apex code feature is required to facilitate this solution?
The requirement is to allow users to select which fields they want to filter by at runtime. In standard (static) SOQL, the fields in the WHERE clause must be defined at compile time (e.g., WHERE Name = :val). Because the fields themselves are not known until the user interacts with the page, the developer cannot write a static query.
Dynamic SOQL is the required feature. It allows the developer to construct the SOQL query string as a text string at runtime, incorporating the specific field names selected by the user, and then execute that string using Database.query(queryString). This provides the flexibility to build queries on the fly based on user input. Metadata API is for configuration changes, Streaming API is for push notifications, and Variable binding (:var) is used in both static and dynamic SOQL but does not solve the issue of changing the field names themselves.