You need to sign in to do that
Don't have an account?
syed 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?
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?
Change from
List<TwilioConfig__c> AdminInfo =TwilioConfig__c.getInstance(Userinfo.getUserId());
to
TwilioConfig__c AdminInfo = TwilioConfig__c.getInstance(Userinfo.getUserId());
All Answers
Please update your method as given in below code:
Hope this solves your problem.
Thanks,
Prashant
Compile Error: unexpected token: 'List' at line 41 column 12
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:
Hope this helps you.
Thanks,
Prashant
Compile Error: unexpected token: 'Map' at line 54 column 12
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
i am getting thsi error Compile Error: Method only supports list type Custom Settings at line 41 column 54
<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>
Here id complete code.
Hope this will fix your problem.
Thanks,
Prashant
i am getting the same error.
Compile Error: Method only supports list type Custom Settings at line 41 column 51
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.
Compile Error: Illegal assignment from TwilioConfig__c to List<TwilioConfig__c> at line 43 column 39
Change from
List<TwilioConfig__c> AdminInfo =TwilioConfig__c.getInstance(Userinfo.getUserId());
to
TwilioConfig__c AdminInfo = TwilioConfig__c.getInstance(Userinfo.getUserId());
Visualforce ErrorHelp for this Page
Select components should have at least one child component of type selectOption or selectOptions