0

I wrote following visualforce page

<apex:page standardController="Case" extensions="WorkOrdersController" sidebar="true">
    <apex:repeat var="testWorkOrder" value="{!listOfRelatedWorkOrders}">
    <apex:outputText value  = " work orders :{!testWorkOrder}" />   
    </apex:repeat>  
</apex:page>

The listOfRelatedWorkOrders property is a List<WorkOrder> for the corresponding case but when I run is it gives me:

System.VisualforceException: Read access denied for WorkOrder, controller action methods may not execute

I checked all the permission and everything is fine since user is administrator.

listOfRelatedWorkOrders = new List<WorkOrder>();
listOfRelatedWorkOrders = [select Id from WorkOrder where CaseId =: fetchedCase.Id ];
9
  • Is the controller declared with without sharing annotation?
    – smukov
    Aug 29, 2016 at 19:55
  • This is the signature : public class WorkOrdersController
    – Vishal
    Aug 29, 2016 at 19:57
  • 1
    Just because your user is an admin does not mean your permissions are high enough by default.
    – Adrian Larson
    Aug 29, 2016 at 19:57
  • 2
    What are the API versions of your Visualforce page and controller extension? WorkOrder wasn't introduced until Spring '16 (API v 36.0)
    – Derek F
    Aug 29, 2016 at 19:57
  • Yeah I know so I checked every permission and everything was fine with all read write access
    – Vishal
    Aug 29, 2016 at 19:58

1 Answer 1

3

From the comments, it appears that this was a matter of checking the API versions being used for the Visualforce page, and the controller extension.

The WorkOrder object was introduced in Spring '16 (API v36.0), meaning that anything that references this object must have its API version set to at least 36.0

Trying to use an sObject defined in a later API version can throw some interesting errors. My brief reproduction tests ended up giving me

  • On my test controller

    Error: Entity is not API accessible

  • On my test Visualforce page

    Error: WorkOrder does not exist

Updating the API versions to at least 36.0 alleviated these issues for me.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .