function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jhartfieldjhartfield 

Apex Batch jobs fail after adding namespace without sending notifications - with resolution

Just wanted to share this as it caused us a lot of headaches.

 

We have a batch jobs set up that has the following QueryLocator definition:

 

global Database.QueryLocator start(Database.batchableContext bc)
{

string sQuery = 'SELECT ID,Name,CustomField__c, CustomField2__c FROM MyCustomObj__c';

return Database.getQueryLocator(sQuery);

}

 

This began failing immediately on us without sending any notification emails about the failures once we added a namespace.  Having no debugging info, this took us a long time to sort out.

 

In the end, we needed to add our new namespace to each field we were querying, like the following:

 

 

global Database.QueryLocator start(Database.batchableContext bc)
{

string sQuery = 'SELECT ID,Name,MyNamespace__CustomField__c, MyNamespace__CustomField2__c FROM MyNamespace__MyCustomObj__c';

return Database.getQueryLocator(sQuery);

}

 

And then it worked!

 

Message Edited by jhartfield on 02-05-2010 08:30 AM
AlexPHPAlexPHP

My batch APEX is also failing.  

 

It fails in Production, but works in the Sandbox.  I cannot figure out why.  

 

How do you figure out what your namespace is?