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
Amit GoyalAmit Goyal 

Issue with Standard WorkOrder Lookup/MasterDetail field on a custom object

I am create a lookup or Master-Detail Relationship on Job__c with StandardObject WorkOrder, The Field got created successfully, I populated the value in the Lookup/MasterDetail field but When I am using that field in my Apex Controller or Triggers, I am getting error, Invalid Field on Job__c.

But I checked the API and Field already exist on the Job__c object itself. I checked that the Standard WorkOrder which is a newly introduced feature in Salesforce is Querable, Updatable etc like all other Standard Object.

Event I am using the Standard WorkOrder on another Custom Object, its functioning well there. What could be the reason. Please suggest or answer, Its a bit urgent.

Thanks,
Amit Goyal
Best Answer chosen by Amit Goyal
Amit GoyalAmit Goyal
Thanks for all your suggestions and input, I got the Solution.
The Controller, in which I were using this, has Version 31.0 and Standard WorkOrder Object was released after that Version.
So I changed the Version of my Controller to 36.0 and Its working now.

All Answers

Deepak GulianDeepak Gulian
Can you please share your code how you are accessing the field in controller or trigger?
Amit GoyalAmit Goyal
I simply created a lookup field with Standard WorkOrder Object, I have the permission on my profile, I could see the field in layout and everywhere. But its not allowing me to put that field in SOQL or update from Apex. Says Field is not available on Object.

The object is queryable, updatable etc like all other Standard Objects.
What could be the issue?
Deepak GulianDeepak Gulian
Can you please cross check the field API name from workbench and copy the API name from there and paste it in SOQL.
Amit GoyalAmit Goyal
I have check the field API, its there Work_Order__c in the Job__c object, I know its a strange question but its happening. The Standard WorkOrder Object is the new feature. I enabled it. I could use with one Custom Object already but dont know why its happening.

I have created case to salesforce but they are not giving answer for this.
Its really a frustation for me now. Could any please suggest some way to get the solution.

Thanks.
Amit GoyalAmit Goyal
Thanks for all your suggestions and input, I got the Solution.
The Controller, in which I were using this, has Version 31.0 and Standard WorkOrder Object was released after that Version.
So I changed the Version of my Controller to 36.0 and Its working now.
This was selected as the best answer