+ Start a Discussion
BCBBCB 

Batch job failed

Hello,

Can anyone help me correct this error? I am not a developer hoping someone can walk me through what steps to take to get this running correctly

Thank You,

Brian

 

8/28/2012 1:00 AM

 Batch ApexFailedFirst error: Inactive User, orgId: 00DA0000000BYaz userId: 005A0000001cdlv011 8/28/2012 1:00 AMDistributionListClass 707A000000QjvGg
Best Answer chosen by Admin (Salesforce Developers) 
HariDineshHariDinesh

Hi,

 

We cannot change the Running user for scheduled JOB.

Click manage of Scheduled Job in Monitoring->scheduled Jobs to see the job schedules

Delete the existing one and create new scheduled job with same schedule.

 

Here you need to schedule this class: scheduledDistributionLists

 

Let me know if you need any more information in this regard.

All Answers

h8r41dh8r41d

Hi,

 

I have some recent experience setting up batch jobs. Can you post any code samples showing how you're going about doing this?

 

I might be able to help if i had some further detail.

 

Gabriel Alack
Contact Us - We Can Help!
Salesforce Superheroes
------------------------------
help@salesforcesuperheroes.com
www.salesforcesuperheroes.com
1-888-407-9578 x122

BCBBCB

Yes, I can post the code however it looks like the user who set this up is inactive and that is why the error is occuring

BCBBCB

Here is a sample to long to post all,

 

// This class is called from the scheduledDistributionLists class
//
// To call Manually:
// Run this from the “Execute Anonymous” function within the debug log or 
// from the same function within the Force.com IDE:
//
// DistributionListClass batch = new DistributionListClass();
// Id batchId = Database.executeBatch(batch);
/////////////////////////////////////////////////////////////////

global class DistributionListClass implements Database.Batchable<sObject>
{
  // Initialize some counters for status
  Integer NbrAccountsInspected = 0;
  Integer NbrListsAdded = 0;
  Integer NbrListsDeleted = 0;
  
  //************ START **************
  // Go grab every active INDIVIDUAL account (Both 'Individual' and 'MHUW Employee')
  global Database.QueryLocator start(Database.BatchableContext BC)
  {
    String query = 'SELECT Id FROM Account WHERE (Account_Type__c = \'Individual\' OR Account_Type__c = \'MHUW Employee\')AND Account_Status__c = \'Active\'';
    return Database.getQueryLocator(query);  
  }
  
  //************ EXECUTE **************
  global void execute(Database.BatchableContext BC, List<sObject> theseAccts)
  {     
    // Name of Distribution List to Create, List of Accounts to link each instance to
    List<Id> newdistListsIDs = new List<Id>();
    List<String> newdistListsNames = new List<String>();
    // Distribution Lists (objects) to delete
    List<SObject> delDistLists = new List<SObject>();  
    // Get all Distribution List names
      Schema.DescribeFieldResult DistListPicklist = Distribution_List__c.Distribution_List_Name__c.getDescribe();
      List<Schema.PicklistEntry> DistListPicklistVals = DistListPicklist.getPicklistValues();
      List<String> DistListNames = new List<String>();
      for (Schema.Picklistentry names: DistListPicklistVals)
      {
        DistListNames.add(names.getValue());
      }
    // Get all currently existing VALID Distribution Lists for these accounts
    List<Distribution_List__c> theseDistLists = [SELECT Id, Account__c, Distribution_List_Name__c, Manage_Manually__c FROM Distribution_List__c WHERE Account__c IN :theseAccts AND Distribution_List_Name__c IN :DistListNames];
    // Get all currently existing INVALID Distribution lists for these accounts
    List<Distribution_List__c> rougeDistLists = [SELECT Id, Account__c, Distribution_List_Name__c, Manage_Manually__c FROM Distribution_List__c WHERE Account__c IN :theseAccts AND Distribution_List_Name__c NOT IN :DistListNames];
      
    
    //***************** Distribution List Rules Here *****************************
    
    // Some year math for our rules....
    String yearsago70 = string.valueof((date.Today().year() - 70));
    String yearsago21 = string.valueof((date.Today().year() - 21));
    String yearsago45 = string.valueof((date.Today().year() - 45));
   
BCBBCB

Can you tell me how to change the running user ?

HariDineshHariDinesh

Hi,

 

We cannot change the Running user for scheduled JOB.

Click manage of Scheduled Job in Monitoring->scheduled Jobs to see the job schedules

Delete the existing one and create new scheduled job with same schedule.

 

Here you need to schedule this class: scheduledDistributionLists

 

Let me know if you need any more information in this regard.

This was selected as the best answer
BCBBCB

HariDinesh.K

 

Thank you, just what I needed