• JayChen
  • NEWBIE
  • 25 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies
Hi there:
Let me start by saying I'm not a developer and very new to development. I'm trying to update a field in on all leads where the business logic results to true, I want the logic to run every 65 minutes. I've written my batch schedule class and schedule class. My batch schedule class works and I can save it in my apex class. However, my schedule class does not work outside of the developer console - everytime I save it as a apex class - it gives me an error message "unexpected token: 'MQLEscalationBatch' at line 1 column 0". Any assistance would be greatly appreciated.

 Batch Class:

global class MQLEscalationBatch implements Database.Batchable<sObject> {
    
    global Database.QueryLocator start(Database.BatchableContext BC)    {
      String query= 'SELECT Id, Company, OwnerId, Escalation_Calculation__c,Status, Inside_Sales_Representative__c 
FROM Lead WHERE Escalation_Calculation__c > 7.50 AND Escalation_Calculation__c < 19.00 AND Inside_Sales_Representative__c != NULL AND IsConverted = FALSE AND Sales_Initial_Last_Modification__c = NULL AND LastActivityDate = NUll ';

        //return Database.QueryLocator(query);

        return Database.getQueryLocator(query);

    }
     
    global void execute(Database.BatchableContext bc, List<Lead> scope)

    {
        for(Lead l: scope)
        {
            l.MQL_Alert__c = TRUE;
            system.debug(l);
        }
        update scope;
        }
        
    global void finish(Database.BatchableContext bc){
        
    }
}


Schedule Class: it gives me an error message "unexpected token: 'MQLEscalationBatch' at line 1 column 0

MQLEscalationBatch b = new MQLEscalationBatch();
database.executeBatch(b);
String sch = '0 05 * * * ?';
String jobID = database.executeBatch(b);
Hello Fellow Salesforce Developers!

I have a apex class that are not covered and was hoping to get help in writing the codes for it. I'm at 35% and have been working on this for about a week now and cannot figure it out. Any help that you could provide is greatly appreciated, thank you in advance. :) The lines that I need to cover are as followed:

   public void execute(SchedulableContext ctx) {
       refreshMetrics(null);}

---
     
 HttpRequest req = new HttpRequest();
       String url = INSTANCE + '/services/data/v33.0/actions/standard/metricRefresh';
       req.setEndpoint(url);
       req.setMethod('POST');
       req.setHeader('Authorization', 'OAuth ' + sessionId);
       req.setHeader('Force-Instance-Url', INSTANCE); 
       req.setHeader('Force-User-Id', userId);
       req.setHeader('Accept', 'application/json');
       req.setHeader('Content-Type', 'application/json');
       req.setBody('{"inputs":[{"metricId":"' + metricId + '"}]}'); // metric id
  
       Http http = new Http();
       HTTPResponse res = http.send(req);
       System.debug(res.getBody());
   }
Hi there:
Let me start by saying I'm not a developer and very new to development. I'm trying to update a field in on all leads where the business logic results to true, I want the logic to run every 65 minutes. I've written my batch schedule class and schedule class. My batch schedule class works and I can save it in my apex class. However, my schedule class does not work outside of the developer console - everytime I save it as a apex class - it gives me an error message "unexpected token: 'MQLEscalationBatch' at line 1 column 0". Any assistance would be greatly appreciated.

 Batch Class:

global class MQLEscalationBatch implements Database.Batchable<sObject> {
    
    global Database.QueryLocator start(Database.BatchableContext BC)    {
      String query= 'SELECT Id, Company, OwnerId, Escalation_Calculation__c,Status, Inside_Sales_Representative__c 
FROM Lead WHERE Escalation_Calculation__c > 7.50 AND Escalation_Calculation__c < 19.00 AND Inside_Sales_Representative__c != NULL AND IsConverted = FALSE AND Sales_Initial_Last_Modification__c = NULL AND LastActivityDate = NUll ';

        //return Database.QueryLocator(query);

        return Database.getQueryLocator(query);

    }
     
    global void execute(Database.BatchableContext bc, List<Lead> scope)

    {
        for(Lead l: scope)
        {
            l.MQL_Alert__c = TRUE;
            system.debug(l);
        }
        update scope;
        }
        
    global void finish(Database.BatchableContext bc){
        
    }
}


Schedule Class: it gives me an error message "unexpected token: 'MQLEscalationBatch' at line 1 column 0

MQLEscalationBatch b = new MQLEscalationBatch();
database.executeBatch(b);
String sch = '0 05 * * * ?';
String jobID = database.executeBatch(b);
Dear friends 

     I have question regarding code coverage. Anyone let me know what are steps to be followed to check the code coverage 
I have a test class and trigger that I have completed. Currently, it is giving me an error on the web services callout. I tried to do some research to understand why it was giving me this error. I know that the piclist field that I am referencing has a web service callout on the lead object but I am refereing to it on the opportunity.  I also do not know where or how to even set up the mock callout to allow myself to obtain code coverage. Here is my code:
@isTest
public class TestUtilityUpdate{
    static testMethod void myTest(){
        Account acc= new Account(name='Test - Properties');
        insert acc;
        
        set<String> strNames = new set<String>{'Los Angeles Department of Water and Power',
            'Adams Ranch',
            'Amarillo Mutual',
            'Anaheim, City of',
            'Arcadia, City of'
            };

        List<Opportunity> lstOpp = new List<Opportunity>();

        for(String str : strNames)
        {
           Opportunity opp = new Opportunity(Water_Agency__c=str,name=str,closedate=system.today(),stagename='Consult to be Scheduled',Accountid=acc.id);
            lstOpp.add(opp);
        }

insert lstOpp;
    
    }
}