I have a Visualforce page used to close cases using a list view button, certain case records should be set to a different close status than others when the button is pressed, unfortunately it appears that getSelected() doesn't include record type values to filter. Is there something I'm missing that can allow me to filter off record type when applying changes en masse to cases via getSelected()?

public with sharing class CloseCaseExtensionMulti {
    private ApexPages.StandardSetController controller;

    public CloseCaseExtensionMulti(ApexPages.StandardSetController controller) {
        this.controller = controller;
    public PageReference doLoad() {
        List<sObject> cases = controller.getSelected();
        for(sObject thisCase : cases) {
            if(thisCase.RecordTypeId == '0120z000000cYd0AAE'){
                thisCase.put('status','Solved (with no response)');
                thisCase.put('status', 'Closed');
        PageReference rval;
        try {
            rval = controller.save();
        } catch (Exception e) {
            return System.currentPageReference();
        return rval;

The record(s) you get from a StandardController or StandardSetController only contain the fields that are rendered in your Visualforce page (as I recall, adding something like html-style="visibility:hidden" or rendered="{![something that evaluates to false here]}" causes Salesforce to not automatically pull in that field).

The general workaround to that is to simply use the standard(Set)Controller to gather record Ids, and then perform a SOQL query to access the field(s) that you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.