0

I have a VF page on a custom object and I am trying to create a button that will essentially mark a checkbox field as TRUE and save the record. I created a controller extension and I have a Repeat element in my VF page. However, when I try to save the page, I get the error:

Error: Unknown property 'Campaign_Create_Request__cStandardController.Create_Case__c'

Does anyone know what I am doing wrong here?

Controller:

public class VF_Controller_CreateCampaignCase{

public List<Campaign_Create_Request__c> CCR {get; set;}


//    private final Campaign_Create_Request__c myCase;
    public VF_Controller_CreateCampaignCase(ApexPages.StandardController myController){
        CCR = new List<Campaign_Create_Request__c>();
    }

    public PageReference CreateCase() {

        CCR[0].Create_Case__c = true;
        insert CCR;
        return null; 
    }
}

VF Page:

<apex:page standardController="Campaign_Create_Request__c" extensions="VF_Controller_CreateCampaignCase">

   <apex:form >
   <apex:repeat value="{!CCR}" var="CC">
  • 1
    Please provide the full visualforce page. – IllusiveBrian Jan 13 '16 at 17:29
  • 1
    Error: Unknown property 'Campaign_Create_Request__cStandardController.Create_Case__c' looks like issue in you other part of code. – Ratan Paul Jan 13 '16 at 17:29
  • 1
    As Namfuak and Ratan said, We need a bit more of your page to figure it out – Sebastian Kessel Jan 13 '16 at 17:37
  • Thanks to both, I was missing a piece in my variable declaration that got rid of the error. Thanks for the help! – J. Neilan Jan 13 '16 at 18:22
  • @Ratan & Sebastian, I spoke too soon. I now get an error: Error: System.ListException: List index out of bounds: 0 Error is in expression '{!CreateCase}' in component <apex:commandButton> in page vf_campaigncreate_view: Class.VF_Controller_CreateCampaignCase.CreateCase: line 15, column 1 Any idea why? – J. Neilan Jan 13 '16 at 18:30
0

You never added any element to your list and were trying to access it. That's why it was throwing the List out of bound exception.

Update your controller:

public VF_Controller_CreateCampaignCase(ApexPages.StandardController myController){
    CCR = new List<Campaign_Create_Request__c>();
    CCR.add((Campaign_Create_Request__c)myController.getRecord());
}
| improve this answer | |

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.