1

i am try to make custom "NEW CASE" page and have problem: I'am receive this message when try to post Case: Unknown property 'CaseSSCFixComponentController.Support_Service_Contract'

Part of page:

<apex:page standardcontroller="Case" tabStyle="Case">
<apex:messages />
<apex:sectionheader title="{!$ObjectType.Case.label} Create" subtitle="{!IF(ISNULL(Case.CaseNumber), 'New Case',Case.CaseNumber)}"/>
<apex:form >
    <apex:pageblock mode="new" title="{!$ObjectType.Case.label} Create">
        <apex:pageblockbuttons >
            <apex:commandbutton value="Save" action="{!Save}"/>
            <apex:commandbutton value="Cancel" action="{!Cancel}"/>
        </apex:pageblockbuttons>
        <apex:inputfield value="{!Case.Subject}" required="true"/>
        <apex:inputfield value="{!Case.Description}" required="true"/>
        ...
        <c:CaseSSCFixComponent />
        <apex:inputfield value="{!Case.ContactId}" required="true"/>
    </apex:pageblock>
</apex:form>

component:

<apex:component controller="CaseSSCFixComponentController" allowDML="true" >
<apex:componentBody >
            <apex:selectList value="{!Support_Service_Contract}" id="Support_Service_Contract__c" multiselect="false" size="1">
                <apex:selectOptions value="{!items}"/>
            </apex:selectList>
</apex:componentBody>    

controller:

public with sharing class CaseSSCFixComponentController {

String[] Support_Service_Contract = new String[]{};

    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        Profile uProfile = [SELECT Id, Name FROM Profile WHERE Id=:userinfo.getProfileId() LIMIT 1];
        if (uProfile.Name != 'Customer Community Login Profile'){

        }
        else{
            User UserInformation = [SELECT Contactid, AccountId FROM User WHERE id=:userinfo.getUserId() LIMIT 1];
            LIST<Support_service_Contract__c> SSC = [SELECT Name, id FROM Support_Service_Contract__c WHERE Status_Active__c = TRUE limit 5 ];
            if (SSC.size() > 0){
                for (Support_service_Contract__c SSCItem : SSC){
                    options.add(new SelectOption(SSCItem.Id, SSCItem.Name));
                }
            }
        }
        return options;
    }

    public String[] getSupport_Service_Contract() {
        return Support_Service_Contract;
    }

    public void setSupport_Service_Contract(String[] Support_Service_Contract) {
        this.Support_Service_Contract = Support_Service_Contract;
    }

}

I need help please, what's wrong? My goal: I'm try to replace annoying "lookup field(with filter)" to "selector" in case form

1 Answer 1

1

Taken from SFDC documentation for apex:selectedList about the value parameter :

A merge field that references the controller class variable that is associated with this selectList. For example, if the name of the associated variable in the controller class is myListSelections, use value="{!myListSelections}" to reference the variable. If multiselect is true, the value attribute must be of type String[] or a List of strings. Otherwise, it must be of type String.

Your option for multi-select is false, so it's expecting a string and not an array of strings

1
  • 1
    thank you, i've just replace String[] to String in controller Commented Feb 19, 2015 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .