1

I wrote the below batch job. It should update the order_vod__c objects comments field with related approval comment from ProcessInstance or ProcessInstanceSteps tables. However, when saving this code I am getting the error - " Error: Compile Error: Entity is not org-accessible at line 1 column 8". I dont have aby idea why this is occuring.

Below is the code-

global class APPROVAL_COMMENTS implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
      String query = 'SELECT Id,Name,  IT_Approval_Comment__c FROM Order_vod__c';
      return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC,List<Order_vod__c> scope)
{
    List<Order_vod__c> updOrdlist = new List<Order_vod__c>();
    for(Order_vod__c order : scope)
    {                       
       updOrdlist =  createOrdCmnts(order);
    }   

    update updOrdlist;
}
public List<Order_vod__c>  createOrdCmnts(Order_vod__c o1) 
        {
            List<Order_vod__c> updOrdlist1 = new List<Order_vod__c>();
            for(Order_vod__c o2:o1) 
            {
                ProcessInstance [] op = [SELECT Id,Status,(SELECT Id,Comments FROM Steps) FROM ProcessInstance limit 1];
                for (ProcessInstance op1 : op) 
                {
                    for (ProcessInstanceStep pis : op1.Steps) 
                    {
                        if(op1.Status == 'Approved') 
                        {
                            o2. IT_Approval_Comment__c = pis.Comments;
                        }
                    }
                }
         updOrdlist1.add(o2);
          }


        return updOrdlist1;
        }       
global void finish(Database.BatchableContext BC)
{
      System.debug(LoggingLevel.WARN,'Batch Job Complete');
}

}

1

This is the message that you get when you try to use an object that you do not have access to or is not available in your Salesforce edition. In your case the problem is probably that you are using Order instead of Order_vod__c in at some points in your code, your fourth line:

query = 'SELECT Id,Name, IT_Approval_Comment__c FROM Order';

should probably read

query = 'SELECT Id,Name, IT_Approval_Comment__c FROM Order_vod__c';

I got this error a lot when we created an object called Invoice__c and I forgot to add the __c part.

|improve this answer|||||
  • 3
    Please don't radically change your quetion. The problem you're having now is that your trying to for-loop over a single item. The function createOrdCmnts gets a single Order_vod__c as a parameter, so you cannot iterate over that. – rael_kid Apr 29 '14 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy