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
Jarosław KołodziejczykJarosław Kołodziejczyk 

How to access Field Service - Service Appointment object from SOQL?

Hi,

Is it possible to access Field Service Lightning (Managed Package) - Service appointment object from SOQL?
I've tried [SELECT Id, Name FROM FSL__Service_Appointment];
[SELECT Id, Name FROM FSL__ServiceAppointment];
[SELECT Id, Name FROM FSL__Service_Appointment__c];
and plethora of other ways, but i always get: 

"sObject type 'FSL__ServiceAppointment__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names."
Best Answer chosen by Jarosław Kołodziejczyk
Amit Chaudhary 8Amit Chaudhary 8
ServiceAppointment
Represents an appointment to complete field service work for a customer. This object is available in API version 38.0 and later.

Please edit your class and change the version to 38.0

Let us know if this will help you
 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please post the screen shot of that object with API name so that we can help you
It should be like below i guess
[SELECT Id, Name FROM FSL__ServiceAppointment__c];
 
Jarosław KołodziejczykJarosław Kołodziejczyk
User-added image

Thing is when i go to Managed Package components it's not visible on the list (couple other objects as well), could it be that salesforce denies access to these objects?
Amit Chaudhary 8Amit Chaudhary 8
Please try below query
 
[SELECT Id, Name FROM FSL__ServiceAppointment__c];

Or
[SELECT Id, Name FROM ServiceAppointment__c];


 
Jarosław KołodziejczykJarosław Kołodziejczyk
Already tried both and some other variations, still getting the same error.
Amit Chaudhary 8Amit Chaudhary 8
are your using standard ServiceAppointment object ?

1) https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_serviceappointment.htm

Then try like below
[SELECT Id, Name FROM ServiceAppointment];

 
Jarosław KołodziejczykJarosław Kołodziejczyk
I'm using the object that is installed with the whole Field Service Lightning app.
And with this line i'm getting : "sObject type 'ServiceAppointment' is not supported."
Jarosław KołodziejczykJarosław Kołodziejczyk
Thing is i'm just about to finish work and will not be able to do this, i've found a workaround using another object so it's not that urgent.
I'll try to find time tomorrow, and if you will also have a spare moment, we can try this.
Amit Chaudhary 8Amit Chaudhary 8
I will suggest you one thing try to login on workbench, Then after login select object from list then it will give you object name

https://workbench.developerforce.com/login.php

Step1 :- Login on workbench with above step
Step2 :- Then select SOQL Query then search your object in Object
User-added image

Step 3:- Then select the field it will give your query like below
User-added image

Let us know if this will help you
 
Jarosław KołodziejczykJarosław Kołodziejczyk
User-added image

Here's code: 

public with sharing class ServiceAppointmentSignController {
        @AuraEnabled
    public static ServiceAppointment[] getData(string recId) {

        return [SELECT Id FROM ServiceAppointment ];
    }
}

and error:

Result: [OPERATION FAILED]: classes/ServiceAppointmentSignController.cls: sObject type 'ServiceAppointment' is not supported. (Line: 5, Column: 16)
Amit Chaudhary 8Amit Chaudhary 8
ServiceAppointment
Represents an appointment to complete field service work for a customer. This object is available in API version 38.0 and later.

Please edit your class and change the version to 38.0

Let us know if this will help you
 
This was selected as the best answer
Jarosław KołodziejczykJarosław Kołodziejczyk
This helped! Thanks! Although why was i creating components with old API version when new one is available?
Jarosław KołodziejczykJarosław Kołodziejczyk
Ok, now i know why this happend, for some reason Sublime with MavensMate plugin, creates metadata in api ver. 36.