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
prasanth kumarprasanth kumar 

entity is not org accessible error in apex class


The below is the all code. error is going if i remove this code.   please help me to solve this. 
 
if(! allquoteowners.contains(Owner.Name))
            {
             

					  if(opp1.stagename == 'Won - Delivery' && daysbetween >= 2)
						 {
						   opp1.Quote_Created__c=true;
						   toUpdateopplist.add(opp1);
						 }   
         
             }


 
global class EmailNotifcation implements Schedulable
{
global integer daysbetween; 
    global static String scheduleIt() 
    {     
        //To start job nxt minuted itself
        dateTime dt=System.now().addMinutes(1); 
        String Csec,Cmin,Chr,Cday,Cmonth,CYear;
        Csec=String.valueof(dt.second());
        Cmin=String.valueof(dt.minute());
        string SchTimer = Csec+' '+Cmin+' * * * ?' ; 
        
        EmailNotifcation  emNOt = new EmailNotifcation();
        
        //String SchTimer = '0 1 12 * * ?'; 
        //String SchTimer = '0 1 * * * ?';
        //String SchTimer =   '0 0 2/3 * * ?';    
        return System.schedule('Email Notification', SchTimer,emNOt );                  
    }   

    global void execute(SchedulableContext SC)
    { 
        emailNotificationMethod();
        System.debug('----------in execute methid');
    }

    public void emailNotificationMethod()
    {
    
		
		list<opportunity> toUpdateopplist= new list<opportunity>();
        // procedure for getting all user names in slesforce
       Map<string,string> allusernamesmap= new map<string,string>() ;
        
       for(user u1:[select id,name from user] )
       {
       allusernamesmap.put(u1.id,u1.name);
       }
       
           
      // getting all quote owner names. 
           
        set<string> allquoteowners = new set<String>();
        
        for(quote q1:[SELECT CreatedById FROM Quote])
        {
          //   .add(q1.CreatedById);
            string name1=allusernamesmap.get(q1.CreatedById);
            allquoteowners.add(name1);
        }
        
       //  Prodecure for getting all opportunites records who is  not created the quote 
        
        list<opportunity> updateopps =new list<opportunity>();       
        
        for(opportunity opp1:[Select id, Owner.Name, Quote_Created__c, ClosedOwn_Date__c, stagename,closedate from Opportunity])
         { 
          daysbetween=opp1.closedate.daysBetween(date.today()); 
           
		   if(! allquoteowners.contains(Owner.Name))
            {
             

					  if(opp1.stagename == 'Won - Delivery' && daysbetween >= 2)
						 {
						   opp1.Quote_Created__c=true;
						   toUpdateopplist.add(opp1);
						 }   
         
             } 


		}  
                           
     //   update  toUpdateopplist;
    }
}

 
Nilesh JNilesh J
Please replace the your code with the below code
for(opportunity opp1:[Select id, Owner.Name, Quote_Created__c, ClosedOwn_Date__c, stagename,closedate from Opportunity])
{ 
	daysbetween=opp1.closedate.daysBetween(date.today()); 

	if(!allquoteowners.contains(opp1.Owner.Name))
	{
		if(opp1.stagename == 'Won - Delivery' && daysbetween >= 2)
		{
		    opp1.Quote_Created__c=true;
			toUpdateopplist.add(opp1);
		}   
	} 
}

You are accessing opportunity owner by Owner.Name without object reference that is the reason you are facing this issue.