• duks
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi,  I have a couple of triggers that sends out sms's based on lead and contact data changes. We are sending these sms's via HTTP to a sms service provider. I get 100% test coverage on my triggers, but 0% on my class... Any help will be appreciated.
TRIGGER

trigger SMSNewLead on Lead (after insert) {
  for(Lead l : Trigger.new){
     //check that the status is new and the owner is not a queue, rating must be hot
     if(l.Status == 'New' && (''+l.OwnerId).startsWith('005') && l.Lead_Rating__c == 'Hot'){
       SmsNewLead.basicSmsNewLead(l.Id, l.Name);
     }
  }
}

 

 

CLASS

public class SmsNewLead {  
  
   //Future annotation to mark the method as async.
   @Future(callout=true) 
   
    public static void basicSmsNewLead(String Id, String Name){       
         
            //get the lead details
            Lead l = [Select Id, Name, Initials__c, Salutation, LastName, Status, OwnerId, MobilePhone FROM Lead WHERE Id=:id  ];           
             
            //Get the user details
            User u = [SELECT Id, LastName, FirstName, Name, Title, MobilePhone FROM User Where id = :l.ownerId];
             
            String Clientsalutation = l.Salutation;
            String ClientInitials = l.Initials__c;
            String Clientlastname = l.LastName;
            String clientcellphonenumber = l.MobilePhone;                                  

            string CurrentDate = string.valueof(System.now());
            CurrentDate = CurrentDate.replace('-','');
            CurrentDate = CurrentDate.replace(' ','');
            CurrentDate = CurrentDate.replace(':','');
			
            String Data = 'data=ZCF\nChanged for the purpose of this post|New Lead: Please contact .......|'+id+'1||';
               Http http = new Http();
               HttpRequest req = new HttpRequest();
               req.setEndpoint('http://correcturl/');
               req.setMethod('POST');
               req.setBody(Data);

               HttpResponse res = http.send(req);
                     
            //check the response
            if (res.getStatusCode() == 200) {   
               //update lead
               l.SMS_To_Consultant__c = true;
               l.SMS_To_Consultant_Result__c = res.getBody();
               update l;
            } else {
               //update lead
               l.SMS_To_Consultant__c = false;
               l.SMS_To_Consultant_Result__c = res.getBody();
               update l;
            }
    }         
 }

 

TEST METHOD
 
 Global Class TestSMSNotifications{
    
    static testMethod void SMSLeadTest(){
        
        //SMS to Consultant - New Lead
        Lead lt = new Lead(FirstName='Test1', LastName='Method', Status = 'New', MobilePhone='0833004553', Initials__c='T', Company='Test', phone='012345678',
        LeadSource='Client', Area__c='Free State', Gender__c='Female', Qualification_1__c='Q1', Qualification_2__c='Q2', Duration_1__c='D1', Institution_1__c='I1', Known_As__c='test' );
        insert lt;

        Test.startTest();
            SmsNewLead.basicSmsNewLead(lt.id, lt.Name); 
        Test.stopTest();        
                
    }  
}

 

 

I would like to add a custom button to the Products related list on the Opportunity page layout, but the interface is acting like this is not possible.  My test button shows up as an option in the other related lists, but not the products.

 

Am I doing something wrong? Is there a limitation that I need to work around? Is it just not allowed at all?

 

I've searched the help and these sites but didn't find anything documented on this.  Looks like you can override the standard buttons, but that doesn't help me.  Would like an additional custom button.

 

Anybody know what is going on here?

 

Thanks.