3

While i am clicking addrow button i am getting the below error -

Error -

common.apex.runtime.impl.ExecutionException: Invalid conversion from runtime type String to List<Id>

Kindly let me know where i am doing wrong -

Apex Class -

public with sharing class RFPController{

    public RFP__c accounts;
        public Custom_Package__c del;
        public List < Custom_Package__c > addattendeeList {get;set;}
        public List < Custom_Package__c > delattendeeList {get;set;}
        public List < Custom_Package__c > attendeeList {get;set;}
        public Integer totalCount {get;set;}

        public Integer rowIndex {get;set;}
        public Integer deleterowIndex {get;set;}
        public List < Custom_Package__c > delAttendees {get;set;}
        public Boolean isRerender{get;set;}
         public Integer numberOfRowToRemove { get; set; }
         public String selectedRowIndex{get;set;} 
         public Integer c{get; set;} 
         private List<SelectOption> options;
         public List<SelectOption> AllName{get;set;}
         public List<SelectOption> AllDept{get;set;}

        private List<Custom_Package__c>  acc {get;set;}

        public RFPController(ApexPages.StandardController controller) {

                isRerender = false;
                accounts =  (RFP__c )controller.getRecord();
                String S = 'Select id, Name, Market__c, State__c, First_Issue__c,Last_Issue__c,Circulation__c,Space_Unit__c,Per_Unit_Open_Rate__c,Space_Discount__c from Custom_Package__c ';
                //totalCount = attendeeList.size();
                attendeeList  = Database.Query(S);
                attendeeList = new List < Custom_Package__c >();
                for(integer i=0;i<1;i++){ 
                attendeeList .add(new Custom_Package__c ());
                }
                delattendeeList = new List < Custom_Package__c > ();
                delattendees = new List < Custom_Package__c > ();

                accounts.Rep_Name__c= Userinfo.getuserId();

                AllName = getMarket();
                Alldept = getDept();
        }

        public void addRow() {
                isRerender = true;
               addattendeeList = new List < Custom_Package__c > ();
                attendeeList.add(new Custom_Package__c ());
                //c=c+1;
                //system.debug('@@@@@@add 2' + rowIndex);
        }

    public List<ID> discountScheduleID {
        get {
            if (discountScheduleID == null) {
                discountScheduleID = new List<ID>();
            }
            return discountScheduleID ;
        }
        set;
    }
      public List<SelectOption> getDept()
    {
        List<SelectOption> options = new List<SelectOption>();
        //options.add(new SelectOption('Select','--Select--'));

        for(Custom_Package__c Proj  :[select Id, Name from Custom_Package__c ] )
             {
                    system.debug('3333333'); 
                    options.add(new SelectOption(Proj.ID,Proj.Name));

             }
        return options;

    }
    public List<SelectOption> getMarket(){
        system.debug('^^^^^^^^ Entered' + discountScheduleID );
            List<SelectOption> options = new List<SelectOption>();

         for(Custom_Package__c Proj1  :[select Id,Market__c from Custom_Package__c where ID=:discountScheduleID  ] )
                {
                    system.debug('3333333' + discountScheduleID ); 
                    options.add(new SelectOption(Proj1.ID,Proj1.Market__c ));

                }

        system.debug('^^^^^^^^ Entered' + options.size());        
        return options;


    }
    public List<ID> selectedMarketIds {
        get {
            if (selectedMarketIds == null) {
                selectedMarketIds = new List<ID>();
            }
            return selectedMarketIds ;
        }
        set;
    }
        public void FindAllName()
    {
        AllName= new List<SelectOption>();
        AllDept= new List<SelectOption>();
        system.debug('!!!!!!! Entered');
        AllName = getMarket();
        Alldept = getDept();
        system.debug('&&&&&&& Entered' + AllName );

    }
}
3

Based on the message, when all the page data is passed back to the controller as a result of the add row button being clicked, a String is being set on a field that has type List<Id>. The two properties of that type are discountScheduleID and selectedMarketIds.

A likely cause is that you have missed the multiselect attribute that causes a list of values to be set:

<apex:selectList value="{!discountScheduleID}" multiselect="true">

Or if only one value should be set don't make the properties list.

| 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.