function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vigneshwaran LoganathanVigneshwaran Loganathan 

Error: Method does not exist or incorrect signature: [String].get(Integer) at line 51 column 34

here I have to get the month, in the picklist value which is having format like YYYY/MM/DD. 

trigger Totalbilledhrs on Billing_MVA__c (after insert, after update)
{
    string sdate;
    string edate;
    string startdate;
    string enddate;
    list<string> testlist = new list<string>();
    list<string> testlist1 = new list<string>();
    public map<string,string> fieldmap = new map<string,string>();
    fieldmap.put('01','Jan');
    fieldmap.put('02','Feb');
    fieldmap.put('03','Mar');
    fieldmap.put('04','Apr');
    fieldmap.put('05','May');
    fieldmap.put('06','Jun');
    fieldmap.put('07','jul');
    fieldmap.put('08','Aug');
    fieldmap.put('09','Sep');
    fieldmap.put('10','Oct');
    fieldmap.put('11','Nov');
    fieldmap.put('12','Dec');
    
   
    List<Opportunity> opplist = new List<Opportunity>();
    integer counter = [select count() from Opportunity where BCRNo__c != null];
    if(counter>0)
    {
        for(Billing_MVA__c Bill : Trigger.new)
        {
            sdate = Bill.startdate__c;
            edate = Bill.end_date__C;
            List<String> stdate = sdate.split('/');
            List<String> endate = edate.split('/');
                 
            if(stdate != null & endate !=null)
            {
                for(string ss : stdate)
                {
                    string ss1 = ss.get(1);         /****************ERROR IN THIS LINE******************/
                    if(fieldmap.containskey(ss1) == true)
                    {
                        startdate = fieldmap.get(ss1);
                    }
                }

                for(string ss2 : endate)
                {
                    string ss3 = ss2.get(1);
                    if(fieldmap.containskey(ss3)== true)
                    {
                        enddate = fieldmap.get(ss3);
                    }
                }
                system.debug('***********'+enddate);
                
            }
        }
    }
    
}
Best Answer chosen by Vigneshwaran Loganathan
ManjunathManjunath
Hi,
Error msage say it all.

String object does not have get method.

you dont need this
for(string ss : stdate)
                {
                    string ss1 = ss.get(1);         /****************ERROR IN THIS LINE******************/
                    if(fieldmap.containskey(ss1) == true)
                    {
                        startdate = fieldmap.get(ss1);
                    }
                }
instead this should be there

                    string ss1 = stdate .get(1);       
                    if(fieldmap.containskey(ss1) == true)
                    {
                        startdate = fieldmap.get(ss1);
                    }

Similarly for others also.

Regards,
MCS