• LukeJCraig
  • NEWBIE
  • 0 Points
  • Member since 2014
  • UK Salesforce.com Manager
  • Fleetcor UK


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Evening all, i am hoping for your help.

I have created this batchable class and tested it in sandbox, all working in sandbox, 100% code coverage. But it fails to run in production.

Preparing timesout. I can't see why as the full sandbox has just as much data as production. I have checked access rights to all necessary fields.

Help please. :-(
 
global class ProspectScoreLeadTask implements Database.Batchable<sObject> {
    
    global integer recordsProcessed = 0;
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([SELECT Id, WhoId, ScoreTask__c FROM Task WHERE WhatId = null AND IsLead__c = true AND CreatedDate = LAST_N_DAYS:365 ORDER BY WhoId ASC, ScoreTask__c ASC]);
        
    }
    
    
    global void execute(Database.BatchableContext bc, List<Task> scope){
        
        Map<Id,Lead> leadMap = new Map<Id,Lead>();
        for(Task tsk : scope){
            leadMap.put(tsk.WhoId,new Lead(Id = tsk.WhoId, ScoreTask__c = tsk.ScoreTask__c));
            recordsProcessed = recordsProcessed + 1;
        }
        Lead[] leadUpdates = new Lead[]{};
            for(Id id : leadMap.keySet()){
                leadUpdates.add(new Lead(Id = id, ScoreTask__c = leadMap.get(id).ScoreTask__c, LastScoreRefresh__c = date.today().addDays(2)));
            }
        update leadUpdates;
        
        
    }
       
    global void finish(Database.BatchableContext bc){
        system.debug(recordsProcessed + ' records processed!');
        //AsyncApexJob job = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =: getJobId()];
    }
}

 
Good evening,
Please could someone help me with testing 3 apex triggers I have created in sandbox?

trigger DrawingStatus on MAI__c (before update) {

for(MAI__c drst:trigger.new){

    if(drst.Short_Term__c == 'Yes'){
        drst.Drawing_Status__c = 'Non Drawer';}
    else if(drst.LC_Max_Vol__c == 0){
        drst.Drawing_Status__c = '';}
    else if(drst.Drawer__c == 'Yes'){
        if(drst.Actual_Variance__c < drst.Permitted_Variance__c){
            drst.Drawing_Status__c = 'Downtrader';}
        else {
            drst.Drawing_Status__c = '';}}
    else {
        drst.Drawing_Status__c = '';}


trigger LTDrawingStatus on MAI__c (before update) {

for(MAI__c lt:trigger.new){

    if(lt.LC_Non_Drawer_Type__c == 'LT'){
        lt.Drawing_Status__c = 'Non Drawer';}


trigger PermittedVariance on MAI__c (before update) {

for(MAI__c pervar:trigger.new){

    if (pervar.Avg_Vol__c > 7500) {
        pervar.Permitted_Variance__c = 0.2;}
    else if (pervar.Avg_Vol__c > 2500) {
        pervar.Permitted_Variance__c = 0.3;}
    else if (pervar.Avg_Vol__c > 675) {
        pervar.Permitted_Variance__c = 0.4;}
    else {
        pervar.Permitted_Variance__c = 0.5;}


Many thanks in advance,

Luke
Evening all, i am hoping for your help.

I have created this batchable class and tested it in sandbox, all working in sandbox, 100% code coverage. But it fails to run in production.

Preparing timesout. I can't see why as the full sandbox has just as much data as production. I have checked access rights to all necessary fields.

Help please. :-(
 
global class ProspectScoreLeadTask implements Database.Batchable<sObject> {
    
    global integer recordsProcessed = 0;
    
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([SELECT Id, WhoId, ScoreTask__c FROM Task WHERE WhatId = null AND IsLead__c = true AND CreatedDate = LAST_N_DAYS:365 ORDER BY WhoId ASC, ScoreTask__c ASC]);
        
    }
    
    
    global void execute(Database.BatchableContext bc, List<Task> scope){
        
        Map<Id,Lead> leadMap = new Map<Id,Lead>();
        for(Task tsk : scope){
            leadMap.put(tsk.WhoId,new Lead(Id = tsk.WhoId, ScoreTask__c = tsk.ScoreTask__c));
            recordsProcessed = recordsProcessed + 1;
        }
        Lead[] leadUpdates = new Lead[]{};
            for(Id id : leadMap.keySet()){
                leadUpdates.add(new Lead(Id = id, ScoreTask__c = leadMap.get(id).ScoreTask__c, LastScoreRefresh__c = date.today().addDays(2)));
            }
        update leadUpdates;
        
        
    }
       
    global void finish(Database.BatchableContext bc){
        system.debug(recordsProcessed + ' records processed!');
        //AsyncApexJob job = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =: getJobId()];
    }
}

 
Good evening,
Please could someone help me with testing 3 apex triggers I have created in sandbox?

trigger DrawingStatus on MAI__c (before update) {

for(MAI__c drst:trigger.new){

    if(drst.Short_Term__c == 'Yes'){
        drst.Drawing_Status__c = 'Non Drawer';}
    else if(drst.LC_Max_Vol__c == 0){
        drst.Drawing_Status__c = '';}
    else if(drst.Drawer__c == 'Yes'){
        if(drst.Actual_Variance__c < drst.Permitted_Variance__c){
            drst.Drawing_Status__c = 'Downtrader';}
        else {
            drst.Drawing_Status__c = '';}}
    else {
        drst.Drawing_Status__c = '';}


trigger LTDrawingStatus on MAI__c (before update) {

for(MAI__c lt:trigger.new){

    if(lt.LC_Non_Drawer_Type__c == 'LT'){
        lt.Drawing_Status__c = 'Non Drawer';}


trigger PermittedVariance on MAI__c (before update) {

for(MAI__c pervar:trigger.new){

    if (pervar.Avg_Vol__c > 7500) {
        pervar.Permitted_Variance__c = 0.2;}
    else if (pervar.Avg_Vol__c > 2500) {
        pervar.Permitted_Variance__c = 0.3;}
    else if (pervar.Avg_Vol__c > 675) {
        pervar.Permitted_Variance__c = 0.4;}
    else {
        pervar.Permitted_Variance__c = 0.5;}


Many thanks in advance,

Luke