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
LAL K 13LAL K 13 

sObject type "OverallCompletionResult__c" is not supported

I have scheduled a scheduler from Installscript class. 
global without sharing class InstallScript implements InstallHandler {
    global void onInstall(InstallContext context){
            List<CronTrigger> ctList8 = [Select Id from CronTrigger where 
                                                  CronJobDetail.Name = 'OverallCompletionUpdate'];
            
            if(ctList8.size()==0){
                String cronStr2 = '0 0 * * * ?';
                
                OverallCompletionUpdateScheduler tl = new 
                                                                           OverallCompletionUpdateScheduler();
                
                String jobID = system.schedule('OverallCompletionUpdate', cronStr2, tl);             
    
            }              
    }
}

My scheduler class is given below
 
global with sharing class OverallCompletionUpdateScheduler implements Schedulable {
   global void execute(SchedulableContext sc) {
      OverallCompletionResultUpdation ovr = new OverallCompletionResultUpdation();
      
      ovr.process();  
   }

}

Given below the OverallCompletionResultUpdation class
 
global with sharing class OverallCompletionResultUpdation{
    global void process(){
        //Initialize variables
        Map<Id,OverallCompletionResult__c> userMap = new 
                 Map<Id,OverallCompletionResult__c>();
        Map<Id,OverallCompletionResult__c> contactMap = new 
                                  Map<Id,OverallCompletionResult__c>(); 
        List<User> userUpdateList = new List<User>();
        List<Contact> contactUpdateList = new List<Contact>();
        Map<Id,User> userIdMap = new Map<Id,User>();
        Map<Id,Contact> contactIdMap = new Map<Id,Contact>();
        
        //Fetch 2000 OverallCompletionResult records with isProcessed = false
        List<OverallCompletionResult__c> ovrList = [Select Id,ContactID__c,UserID__c,TotalCoursesAssigned__c,TotalCoursesCompleted__c,TotalLearningPathAssigned__c,TotalLearningPathsCompleted__c,OverallUserCourseCompletionPercentage__c,OverallUserLearningPathCompletionPercent__c From OverallCompletionResult__c Where isProcessed__c=false and ContactId__r.Deactivate_From_Litmos__c=:false limit 2000];    


//Calculation logic goes here
}
}
After installation when the sceduler runs It gives the above error "sObject type "OverallCompletionResult__c" is not supported" on the below line in the OverallCompletionResultUpdation class.
 
List<OverallCompletionResult__c> ovrList = [Select Id,ContactID__c,UserID__c,TotalCoursesAssigned__c,TotalCoursesCompleted__c,TotalLearningPathAssigned__c,TotalLearningPathsCompleted__c,OverallUserCourseCompletionPercentage__c,OverallUserLearningPathCompletionPercent__c From OverallCompletionResult__c Where isProcessed__c=false and ContactId__r.Deactivate_From_Litmos__c=:false limit 2000];

Please help me on this. Is this because of the sharing rules on scheduler?

Thanks for the help
LBKLBK
It could be related to the permission.

Who ever is running this (in who's name is this scheduled), can you check if the user has View All access to OverallCompletionResult__c object?
LAL K 13LAL K 13
The scheduler is created by a fake "installation user" and not able to access the user.
LBKLBK
Can you either recreate the schedule with a different user (who has access to the object) or remove With Sharing from the code?