You need to sign in to do that
Don't have an account?
LukeJCraig
Soql query not working in production
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. :-(
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()]; } }
Just to nail down the issue, have you tried executing the suspected query in production developer console (if not queryeditor, anonymous window).
If not, I suggest you to try that as the issue is environment dependent.
Hope this helps
To nail down the issue causing part, (it is just a suggestion, if you have not tried) just try,
SELECT Id, WhoId, ScoreTask__c FROM Task
then try adding where clause with one condition, then you may add orderby clause.