+ Start a Discussion
syed akramsyed akram 

Compile Error: expecting a left angle bracket, found 'getPersonList' at line 15 column 16

here is my cntroller code
 public with sharing class TwilioCloudCommunicationClass {  
      
    // Public Properties  
    public String SelectedMobileNumber{get;set;}  
    public String OtherMobileNumber{get;set;}  
    public String textMessage{get;set;}
    // Default construtor  
    public TwilioCloudCommunicationClass()  
    {  
        SelectedMobileNumber  = '' ;  
        OtherMobileNumber = '' ;  
    }  
      
    Public List getPersonList()  
    {  
        Try{  
            List localList = new List();  
            localList.add(new SelectOption('' , '--Select--'));  
            for(contact cont : [select Name,MobilePhone from contact where TwilioRegisteredUser__c = true ])  
            {  
                localList.add(new SelectOption(cont.MobilePhone , cont.Name));            
            }        
            localList.add(new SelectOption('other' , 'Other'));  
            return localList ;  
        }  
        
        catch(Exception e)  
        {  
            ApexPages.addMessages(e);        
            return null;  
        }  
        
    }  
      
    public void SendSMS()  
    {  
        Try{        
            SelectedMobileNumber = (SelectedMobileNumber == '')? OtherMobileNumber:SelectedMobileNumber ;  
            if(SelectedMobileNumber != '')  
            {  
                List AdminInfo = TwilioConfig__c.getall().values();  
                String ACCOUNT_SID = '';  
                String AUTH_TOKEN  = '' ;              
                String SenderMobileNumber = '' ;  
                // Informaton getting from custom setting  
                if(AdminInfo.size()>0)  
                {            
                    ACCOUNT_SID             = AdminInfo[0].AccountSid__c;  
                    AUTH_TOKEN              = AdminInfo[0].AuthToken__c;                  
                    SenderMobileNumber      = AdminInfo[0].Admin_Mobile_Number__c;      
                }              
                TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);  
                 
                Map properties = new Map {  
                            'To'   => SelectedMobileNumber ,  
                            'From' => SenderMobileNumber,  
                            'Body' => textMessage  
                    };  
                TwilioSMS message = client.getAccount().getSmsMessages().create(properties);  
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Message has been sent'));  
            }  
            else  
            {  
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'Pelase provide valid Mobile Number '));  
            }  
        }catch(Exception e )  
        {  
            ApexPages.addMessages(e);        
            return ;  
        }    
    }       
    } 
Can anyone help me to solve this?
Best Answer chosen by syed akram
Arunkumar RArunkumar R
Syed,

Change from 

List<TwilioConfig__c> AdminInfo =TwilioConfig__c.getInstance(Userinfo.getUserId());

to

TwilioConfig__c AdminInfo = TwilioConfig__c.getInstance(Userinfo.getUserId());
 

All Answers

Prashant WayalPrashant Wayal
Hi Syed,

Please update your method as given in below code:
Public List<SelectOption> getPersonList()  
    {  
        Try{  
            List<SelectOption> localList = new List<SelectOption>();  
            localList.add(new SelectOption('' , '--Select--'));  
            for(contact cont : [select Name,MobilePhone from contact where TwilioRegisteredUser__c = true ])  
            {  
                localList.add(new SelectOption(cont.MobilePhone , cont.Name));            
            }        
            localList.add(new SelectOption('other' , 'Other'));  
            return localList ;  
        }  
        
        catch(Exception e)  
        {  
            ApexPages.addMessages(e);        
            return null;  
        }  
        
    }

Hope this solves your problem.

Thanks,
Prashant
syed akramsyed akram
after updating the above code i am getting this error
Compile Error: unexpected token: 'List' at line 41 column 12
Prashant WayalPrashant Wayal
Hi Syed,

In your code, you are using only List AdminInfo = TwilioConfig__c.getall().values();  
But the syntax of List collection is like:
List<SObjectName> varname = new List<SObjectName>();

Here SObjectName = any standard or custom obejct or datatype used in salesforce like String, Integer, Decimal, Account, Contact, etc.

Please update your code accordingly. 

In your case, can you try this:
 
List<TwilioConfig__c> adminInfo = TwilioConfig__c.getall().values();


Hope this helps you.

Thanks,
Prashant
syed akramsyed akram
now i am getting error
Compile Error: unexpected token: 'Map' at line 54 column 12
syed akramsyed akram
after i change the 54 line to
Map<String, String> properties = new Map<String, String>

now i am getting this error
Compile Error: Method only supports list type Custom Settings at line 41 column 47
 
syed akramsyed akram
hi arunkumar ,
i am getting thsi error Compile Error: Method only supports list type Custom Settings at line 41 column 54
 
syed akramsyed akram
and here is my vf page for that controller
<apex:page controller="TwilioCloudCommunicationClass" id="pgId" showheader="true" sidebar="false" tabstyle="Account">
<style>
    .otherBoxClass
    {
        display : "none" ;
    }
</style>
<apex:form>
    <apex:outputpanel id="MsgPanelId">
        <apex:pagemessages>
    </apex:pagemessages></apex:outputpanel>
    <apex:pageblock>
        <apex:pageblocksection columns="2" title="SMS Section">        
            <apex:pageblocksectionitem>                  
                    <apex:outputlabel value="Select Receiver Name">
                    <apex:selectlist rendered="{!PersonList.size >0}" size="1" value="{!SelectedMobileNumber}">
                        <apex:actionsupport event="onchange" rerender="OtherBoxId">                                          
                        <apex:selectoptions value="{!PersonList}"></apex:selectoptions>
                    </apex:actionsupport></apex:selectlist>          
           </apex:outputlabel></apex:pageblocksectionitem>
           <apex:pageblocksectionitem>
               <apex:outputlabel value="Other Mobile Number">
               <apex:outputpanel id="OtherBoxId" styleclass="otherBoxClass">                  
                   <apex:inputtext value="{!OtherMobileNumber}">
              </apex:inputtext></apex:outputpanel>
           </apex:outputlabel></apex:pageblocksectionitem>
           <apex:pageblocksectionitem>
                <apex:outputlabel value="Type Message">
                <apex:outputpanel>
                   <apex:inputtext maxlength="160" value="{!textMessage}">              
                   <apex:commandbutton action="{!SendSMS}" rerender="MsgPanelId" value="Send SMS">    
                </apex:commandbutton></apex:inputtext></apex:outputpanel>        
           </apex:outputlabel></apex:pageblocksectionitem>        
       </apex:pageblocksection>
    </apex:pageblock>
</apex:form>
</apex:page>

 
Prashant WayalPrashant Wayal
Hi Syed,

Here id complete code. 
public with sharing class TwilioCloudCommunicationClass {  
    
    // Public Properties  
    public String SelectedMobileNumber{get;set;}  
    public String OtherMobileNumber{get;set;}  
    public String textMessage{get;set;}
    // Default construtor  
    public TwilioCloudCommunicationClass()  
    {  
        SelectedMobileNumber  = '';  
        OtherMobileNumber = '';  
    }  
    
    Public List<SelectOption> getPersonList()  
    {  
        Try{  
            List<SelectOption> localList = new List<SelectOption>();  
            localList.add(new SelectOption('' , '--Select--'));  
            for(contact cont : [select Name,MobilePhone from contact where TwilioRegisteredUser__c = true]) 
            {  
                localList.add(new SelectOption(cont.MobilePhone , cont.Name));            
            }        
            localList.add(new SelectOption('other' , 'Other'));  
            return localList ;  
        }  
        
        catch(Exception e)  
        {  
            ApexPages.addMessages(e);        
            return null;  
        }  
        
    }  
    
    public void SendSMS()  
    {  
        Try{        
            SelectedMobileNumber = (SelectedMobileNumber == '')? OtherMobileNumber:SelectedMobileNumber ;  
            if(SelectedMobileNumber != '')  
            {  
                List<TwilioConfig__c> AdminInfo = TwilioConfig__c.getall().values();  
                String ACCOUNT_SID = '';  
                String AUTH_TOKEN  = '' ;              
                String SenderMobileNumber = '' ;  
                // Informaton getting from custom setting  
                if(AdminInfo.size()>0)  
                {            
                    ACCOUNT_SID             = AdminInfo[0].AccountSid__c;  
                    AUTH_TOKEN              = AdminInfo[0].AuthToken__c;                  
                    SenderMobileNumber      = AdminInfo[0].Admin_Mobile_Number__c;      
                }              
                TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);  
                
                Map<String, String> properties = new Map<String, String>{  
                    'To'   => SelectedMobileNumber ,  
                        'From' => SenderMobileNumber,  
                        'Body' => textMessage  
                        };  
                            TwilioSMS message = client.getAccount().getSmsMessages().create(properties);  
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Message has been sent'));  
            }  
            else  
            {  
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'Pelase provide valid Mobile Number '));  
            }  
        }catch(Exception e )  
        {  
            ApexPages.addMessages(e);        
            return ;  
        }    
    }       
}

Hope this will fix your problem.

Thanks,
Prashant
syed akramsyed akram
Hi Prashant,
   i am getting the same error.
Compile Error: Method only supports list type Custom Settings at line 41 column 51
 
Arunkumar RArunkumar R
Hi Syed,

In your code you are trying to access Hierarchy Custom Setting.  You can check out the way of accessing from the below link

https://help.salesforce.com/HTViewHelpDoc?id=cs_accessing.htm&language=en_US

TwilioConfig__c AdminInfo = TwilioConfig__c.getInstance(Userinfo.getUserId());

In the above line i have passed current user id. Here you can pass UserId or Profile. Based on your need you can dynamically pass it.
 
public with sharing class TwilioCloudCommunicationClass {  
    
    // Public Properties  
    public String SelectedMobileNumber{get;set;}  
    public String OtherMobileNumber{get;set;}  
    public String textMessage{get;set;}
    // Default construtor  
    public TwilioCloudCommunicationClass()  
    {  
        SelectedMobileNumber  = '';  
        OtherMobileNumber = '';  
    }  
    
    Public List<SelectOption> getPersonList()  
    {  
        Try{  
            List<SelectOption> localList = new List<SelectOption>();  
            localList.add(new SelectOption('' , '--Select--'));  
            for(contact cont : [select Name,MobilePhone from contact where TwilioRegisteredUser__c = true]) 
            {  
                localList.add(new SelectOption(cont.MobilePhone , cont.Name));            
            }        
            localList.add(new SelectOption('other' , 'Other'));  
            return localList ;  
        }  
        
        catch(Exception e)  
        {  
            ApexPages.addMessages(e);        
            return null;  
        }  
        
    }  
    
    public void SendSMS()  
    {  
        Try{        
            SelectedMobileNumber = (SelectedMobileNumber == '')? OtherMobileNumber:SelectedMobileNumber ;  
            if(SelectedMobileNumber != '')  
            {  
                List<TwilioConfig__c> AdminInfo = TwilioConfig__c.getInstance(Userinfo.getUserId());
                String ACCOUNT_SID = '';  
                String AUTH_TOKEN  = '' ;              
                String SenderMobileNumber = '' ;  
                // Informaton getting from custom setting  
                if(AdminInfo.size()>0)  
                {            
                    ACCOUNT_SID             = AdminInfo.AccountSid__c;  
                    AUTH_TOKEN              = AdminInfo.AuthToken__c;                  
                    SenderMobileNumber      = AdminInfo.Admin_Mobile_Number__c;      
                }              
                TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);  
                
                Map<String, String> properties = new Map<String, String>{  
                    'To'   => SelectedMobileNumber ,  
                        'From' => SenderMobileNumber,  
                        'Body' => textMessage  
                        };  
                            TwilioSMS message = client.getAccount().getSmsMessages().create(properties);  
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Message has been sent'));  
            }  
            else  
            {  
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'Pelase provide valid Mobile Number '));  
            }  
        }catch(Exception e )  
        {  
            ApexPages.addMessages(e);        
            return ;  
        }    
    }       
}

 
syed akramsyed akram
again error
Compile Error: Illegal assignment from TwilioConfig__c to List<TwilioConfig__c> at line 43 column 39
 
Arunkumar RArunkumar R
Syed,

Change from 

List<TwilioConfig__c> AdminInfo =TwilioConfig__c.getInstance(Userinfo.getUserId());

to

TwilioConfig__c AdminInfo = TwilioConfig__c.getInstance(Userinfo.getUserId());
 
This was selected as the best answer
syed akramsyed akram
hi now i am getting this error

Visualforce ErrorHelp for this Page
Select components should have at least one child component of type selectOption or selectOptions