• Mohammad Azam
  • NEWBIE
  • 35 Points
  • Member since 2015
  • Salesforce Consultant


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
Hi
I am trying to SMS Gateway Integration. I am struck at a point. 
I am invoking the class with Javascript button. So when the button is clicked, the sms is sent. But i am an errors. Please help.

My javaScript button code
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}


var callout = "" + sforce.apex.execute("DisplaySMSQueueListViewRecords","SedingSMSManullay",
    {msg:"{!Customer__c.Vehicle__c}",phone:"{!Customer__c.Phone__c}"}); 
    
    alert("SMS Sent");

My Apex Class
 
Global class DisplaySMSQueueListViewRecords 
{
    //variables
     @future(Callout=true)
    //Sending SMS Manually
    Webservice static void SedingSMSManullay(String msg,String phone)
    {               
    
                     String mobileNumber=phone;
                      String SendSMSString = msg;     
                        Http h = new Http();
                        HttpRequest req = new HttpRequest();
                        req.setEndpoint('http://bhashsms.in/api/sendmsg.php?user=xxx&pass=123456&sender=xxx&phone='+mobileNumber+'&text='+SendSMSString+'&priority=sdnd&stype=normal');        								
                        req.setHeader('Accept', 'text/xml');
                        req.setHeader('Content-Type' , 'text/plain');
                        req.setMethod('GET');
 						HttpResponse res;
        				if(!Test.isRunningTest())
                        	res = h.send(req);
        				
                       // Responsebody =res.getBody();
                        System.debug('***********'+res);
     }      
 }

Error I am getting when i click the button or execute the class from dev console.
 
00:11:22:020 FATAL_ERROR System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = http://bhashsms.in/api/sendmsg.php?user=xxx&pass=xxx&sender=xxx&phone=900000003&text=Message&priority=sdnd&stype=normal
I tried adding the Endpoint URL in the Remote Site Setting as "http://bhashsms.com" but it is still throwing the same error. 

Please help
 
Visualforce Page
<apex:page Controller="RoomOccupancyRptCntl" docType="html-5.0">    
    <script language="javascript">
      
       function getResultMonth(param,freq) {
           //alert(freq);
           if(freq=='monthly'){
                         switch (param) {
                      case "JAN":
                          param=1;                        
                        break;
                      case "FEB":
                          param=2;                         
                        break;
                      case "MAR":
                          param=3;                         
                        break;
                      case "APR":
                          param=4;                         
                        break;                     
                      case "MAY":
                          param=5;                         
                        break;
                        case "JUN":
                          param=6;                         
                        break;
                        case "JUL":
                          param=7;                         
                        break;
                        case "AUG":
                          param=8;                         
                        break;
                        case "SEP":
                          param=9;                         
                        break;
                        case "OCT":
                          param=10;                         
                        break;
                        case "NOV":
                          param=11;                         
                        break;
                        case "DEC":
                          param=12;                         
                        break;
                                              
                    } 
                    additionalFilter(param); 
           }
           
         else{
         additionalFilter(param);
         }
           
           
       }
    </script>    
<apex:form >
        <apex:actionFunction name="additionalFilter" action="{!additionalFilter}" reRender="out">
                    
       <apex:pageBlock title="Additional Filter" id="out" >
     
       <apex:pageBlockSection columns="1">
          <apex:pageBlockTable value="{!subBookings}" var="booking" >         
             <apex:column value="{!booking.Account__c}"/>
             <apex:column value="{!booking.Contact__c}"/>
             <apex:column value="{!booking.Virtual_Office_Type__c}"/>
             <apex:column value="{!booking.M__c}"/>
             <apex:column value="{!booking.Office_No__c}"/>
             <apex:column value="{!booking.Meeting_Room_No__c}"/>
             <apex:column value="{!booking.Actual_Start_Date_Time__c}"/>
             <apex:column value="{!booking.End_Date_Time__c}"/>
          </apex:pageBlockTable>
          </apex:pageBlockSection>
       </apex:pageBlock>
      

   </apex:form>   
</apex:page>

Controller 
 
public class RoomOccupancyRptCntl {


 public List < My_Sales__c > subBookings {
  get;
  set;
 }



 public PageReference additionalFilter() {
  integer selectedMonth = integer.valueOf(Apexpages.currentPage().getParameters().get('Param'));
  List < My_Sales__c > jan15 = new List < My_Sales__c > ();
  List < My_Sales__c > year16 = new List < My_Sales__c > ();
  List < My_Sales__c > year17 = new List < My_Sales__c > ();
  List < My_Sales__c > year18 = new List < My_Sales__c > ();
  List < My_Sales__c > year19 = new List < My_Sales__c > ();
  List < My_Sales__c > year20 = new List < My_Sales__c > ();
  subBookings = new List < My_Sales__c > ();
  Integer year = 2015;
  if (selyear != 'None')
   year = Integer.valueof(selyear);
  Integer endYear = year + 5;

  jan15 = [Select Contact_Name__c, Contact__c, Account__c, Virtual_Office_Type__c, M__c, Office_No__c,
   Meeting_Room_No__c, Actual_Start_Date_Time__c, End_Date_Time__c, Active__c, X2015_January__c,
   X2015_February__c, X2015_March__c, X2015_April__c, X2015_May__c, X2015_June__c, X2015_July__c,
   X2015_August__c, X2015_September__c, X2015_October__c, X2015_November__c, X2015_December__c
   FROM My_Sales__c
  ];

  year16 = [Select Contact_Name__c, Contact__c, Account__c, Virtual_Office_Type__c, M__c, Office_No__c,
   Meeting_Room_No__c, Actual_Start_Date_Time__c, End_Date_Time__c, Active__c, X2016_January__c,
   X2016_February__c, X2016_March__c, X2016_April__c, X2016_May__c, X2016_June__c, X2016_July__c,
   X2016_August__c, X2016_September__c, X2016_October__c, X2016_November__c, X2016_December__c
   FROM My_Sales__c
  ];

  year17 = [Select Contact_Name__c, Contact__c, Account__c, Virtual_Office_Type__c, M__c, Office_No__c,
   Meeting_Room_No__c, Actual_Start_Date_Time__c, End_Date_Time__c, Active__c, X2017_January__c,
   X2017_February__c, X2017_March__c, X2017_April__c, X2017_May__c, X2017_June__c, X2017_July__c,
   X2017_August__c, X2017_September__c, X2017_October__c, X2017_November__c, X2017_December__c
   FROM My_Sales__c
  ];

  year18 = [Select Contact_Name__c, Contact__c, Account__c, Virtual_Office_Type__c, M__c, Office_No__c,
   Meeting_Room_No__c, Actual_Start_Date_Time__c, End_Date_Time__c, Active__c, X2018_January__c,
   X2018_February__c, X2018_March__c, X2018_April__c, X2018_May__c, X2018_June__c, X2018_July__c,
   X2018_August__c, X2018_September__c, X2018_October__c, X2018_November__c, X2018_December__c
   FROM My_Sales__c
  ];

  year19 = [Select Contact_Name__c, Contact__c, Account__c, Virtual_Office_Type__c, M__c, Office_No__c,
   Meeting_Room_No__c, Actual_Start_Date_Time__c, End_Date_Time__c, Active__c, X2019_January__c,
   X2019_February__c, X2019_March__c, X2019_April__c, X2019_May__c, X2019_June__c, X2019_July__c,
   X2019_August__c, X2019_September__c, X2019_October__c, X2019_November__c, X2019_December__c
   FROM My_Sales__c
  ];

  year20 = [Select Contact_Name__c, Contact__c, Account__c, Virtual_Office_Type__c, M__c, Office_No__c,
   Meeting_Room_No__c, Actual_Start_Date_Time__c, End_Date_Time__c, Active__c, X2020_January__c,
   X2020_February__c, X2020_March__c, X2020_April__c, X2020_May__c, X2020_June__c, X2020_July__c,
   X2020_August__c, X2020_September__c, X2020_October__c, X2020_November__c, X2020_December__c
   FROM My_Sales__c
  ];


  for (My_Sales__c ms: jan15) {
   if (selectedMonth == 1 && year == 2015 && ms.X2015_January__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 2 && year == 2015 && ms.X2015_February__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 3 && year == 2015 && ms.X2015_March__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 4 && year == 2015 && ms.X2015_April__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 5 && year == 2015 && ms.X2015_May__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 6 && year == 2015 && ms.X2015_June__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 7 && year == 2015 && ms.X2015_July__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 8 && year == 2015 && ms.X2015_August__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 9 && year == 2015 && ms.X2015_September__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 10 && year == 2015 && ms.X2015_October__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 11 && year == 2015 && ms.X2015_November__c == true) {
    subBookings.add(ms);
   } else if (selectedMonth == 12 && year == 2015 && ms.X2015_December__c == true) {
    subBookings.add(ms);
   }
  }
  for (My_Sales__c mp: year16) {
   if (selectedMonth == 1 && year == 2016 && mp.X2016_January__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 2 && year == 2016 && mp.X2016_February__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 3 && year == 2016 && mp.X2016_March__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 4 && year == 2016 && mp.X2016_April__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 5 && year == 2016 && mp.X2016_May__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 6 && year == 2016 && mp.X2016_June__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 7 && year == 2016 && mp.X2016_July__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 8 && year == 2016 && mp.X2016_August__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 9 && year == 2016 && mp.X2016_September__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 10 && year == 2016 && mp.X2016_October__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 11 && year == 2016 && mp.X2016_November__c == true) {
    subBookings.add(mp);
   } else if (selectedMonth == 12 && year == 2016 && mp.X2016_December__c == true) {
    subBookings.add(mp);
   }
  }

  for (My_Sales__c ma: year17) {
   if (selectedMonth == 1 && year == 2017 && ma.X2017_January__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 2 && year == 2017 && ma.X2017_February__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 3 && year == 2017 && ma.X2017_March__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 4 && year == 2017 && ma.X2017_April__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 5 && year == 2017 && ma.X2017_May__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 6 && year == 2017 && ma.X2017_June__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 7 && year == 2017 && ma.X2017_July__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 8 && year == 2017 && ma.X2017_August__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 9 && year == 2017 && ma.X2017_September__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 10 && year == 2017 && ma.X2017_October__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 11 && year == 2017 && ma.X2017_November__c == true) {
    subBookings.add(ma);
   } else if (selectedMonth == 12 && year == 2017 && ma.X2017_December__c == true) {
    subBookings.add(ma);
   }
  }

  for (My_Sales__c mo: year18) {
   if (selectedMonth == 1 && year == 2018 && mo.X2018_January__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 2 && year == 2018 && mo.X2018_February__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 3 && year == 2018 && mo.X2018_March__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 4 && year == 2018 && mo.X2018_April__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 5 && year == 2018 && mo.X2018_May__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 6 && year == 2018 && mo.X2018_June__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 7 && year == 2018 && mo.X2018_July__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 8 && year == 2018 && mo.X2018_August__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 9 && year == 2018 && mo.X2018_September__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 10 && year == 2018 && mo.X2018_October__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 11 && year == 2018 && mo.X2018_November__c == true) {
    subBookings.add(mo);
   } else if (selectedMonth == 12 && year == 2018 && mo.X2018_December__c == true) {
    subBookings.add(mo);
   }
  }

  for (My_Sales__c me: year19) {
   if (selectedMonth == 1 && year == 2019 && me.X2019_January__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 2 && year == 2019 && me.X2019_February__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 3 && year == 2019 && me.X2019_March__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 4 && year == 2019 && me.X2019_April__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 5 && year == 2019 && me.X2019_May__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 6 && year == 2019 && me.X2019_June__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 7 && year == 2019 && me.X2019_July__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 8 && year == 2019 && me.X2019_August__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 9 && year == 2019 && me.X2019_September__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 10 && year == 2019 && me.X2019_October__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 11 && year == 2019 && me.X2019_November__c == true) {
    subBookings.add(me);
   } else if (selectedMonth == 12 && year == 2019 && me.X2019_December__c == true) {
    subBookings.add(me);
   }
  }

  for (My_Sales__c mx: year20) {
   if (selectedMonth == 1 && year == 2020 && mx.X2020_January__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 2 && year == 2020 && mx.X2020_February__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 3 && year == 2020 && mx.X2020_March__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 4 && year == 2020 && mx.X2020_April__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 5 && year == 2020 && mx.X2020_May__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 6 && year == 2020 && mx.X2020_June__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 7 && year == 2020 && mx.X2020_July__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 8 && year == 2020 && mx.X2020_August__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 9 && year == 2020 && mx.X2020_September__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 10 && year == 2020 && mx.X2020_October__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 11 && year == 2020 && mx.X2020_November__c == true) {
    subBookings.add(mx);
   } else if (selectedMonth == 12 && year == 2020 && mx.X2020_December__c == true) {
    subBookings.add(mx);
   }
  }

  return null;
 }


}

Can some one please help me with the test class.
I have a Picklist in my Lead ( Resource  = Cash & Insurance), I have 2 record types and page Layouts in Opportunity called Cash & Insurance.
If i select Cash in Lead picklist and convert the Lead, the Opportunity created should be with Cash Record type & If i select Insurance in Lead picklist and convert the Lead, the Opportunity created should be with Insurance Record type. 
Can someone write a trigger ?

Please Help
I have a Picklist in my Lead ( Resource  = Cash & Insurance), I have 2 record types and page Layouts in Opportunity called Cash & Insurance.
If i select Cash in Lead picklist and convert the Lead, the Opportunity created should be with Cash Record type & If i select Insurance in Lead picklist and convert the Lead, the Opportunity created should be with Insurance Record type. 
Is there a workflow, process builder or trigger ?

Please Help
There are 2 record types & Page Layouts in lead (Cash and Insurance) & 2 record types & Page Layouts in Opportunity (Cash and Insurance).

If i create a lead in cash record type , when i convert the lead it should convert to opportunity in cash record type and if i create a lead in insurance record type, it should convert to opportunity with insurance record type.

Please Help
 
Hi
I am trying to SMS Gateway Integration. I am struck at a point. 
I am invoking the class with Javascript button. So when the button is clicked, the sms is sent. But i am an errors. Please help.

My javaScript button code
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}


var callout = "" + sforce.apex.execute("DisplaySMSQueueListViewRecords","SedingSMSManullay",
    {msg:"{!Customer__c.Vehicle__c}",phone:"{!Customer__c.Phone__c}"}); 
    
    alert("SMS Sent");

My Apex Class
 
Global class DisplaySMSQueueListViewRecords 
{
    //variables
     @future(Callout=true)
    //Sending SMS Manually
    Webservice static void SedingSMSManullay(String msg,String phone)
    {               
    
                     String mobileNumber=phone;
                      String SendSMSString = msg;     
                        Http h = new Http();
                        HttpRequest req = new HttpRequest();
                        req.setEndpoint('http://bhashsms.in/api/sendmsg.php?user=xxx&pass=123456&sender=xxx&phone='+mobileNumber+'&text='+SendSMSString+'&priority=sdnd&stype=normal');        								
                        req.setHeader('Accept', 'text/xml');
                        req.setHeader('Content-Type' , 'text/plain');
                        req.setMethod('GET');
 						HttpResponse res;
        				if(!Test.isRunningTest())
                        	res = h.send(req);
        				
                       // Responsebody =res.getBody();
                        System.debug('***********'+res);
     }      
 }

Error I am getting when i click the button or execute the class from dev console.
 
00:11:22:020 FATAL_ERROR System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = http://bhashsms.in/api/sendmsg.php?user=xxx&pass=xxx&sender=xxx&phone=900000003&text=Message&priority=sdnd&stype=normal
I tried adding the Endpoint URL in the Remote Site Setting as "http://bhashsms.com" but it is still throwing the same error. 

Please help
 
Gurus, 
Is there a way I could default lead notification when the lead owner is changed. Please let me know. RIght now, it is defaulted to uncheck and user needs to check to send email. I created a workflow to send notification when the user changes but the system sends two notifcations if "Send email notification" check box is checked.

Any suggestions?
-Gaurav
I have a Picklist in my Lead ( Resource  = Cash & Insurance), I have 2 record types and page Layouts in Opportunity called Cash & Insurance.
If i select Cash in Lead picklist and convert the Lead, the Opportunity created should be with Cash Record type & If i select Insurance in Lead picklist and convert the Lead, the Opportunity created should be with Insurance Record type. 
Can someone write a trigger ?

Please Help
There are 2 record types & Page Layouts in lead (Cash and Insurance) & 2 record types & Page Layouts in Opportunity (Cash and Insurance).

If i create a lead in cash record type , when i convert the lead it should convert to opportunity in cash record type and if i create a lead in insurance record type, it should convert to opportunity with insurance record type.

Please Help
 
Hi,

I would like to have all new Opportunities start with a default stage value of Stage 1: Initial Interest. I tried a WF rule but was unsuccessful. (below)

I think the best way to do this is with a trigger but i cannot find how to setup a trigger to insert a default value when the opp is created.

Please Help!!



User-added image