Get Service Appointments

A service appointment represents an appointment booked through Salesforce Scheduler. Use the query request on the ServiceAppointment object to retrieve a list of service appointments.

Create a page where you can show the service appointments for a logged in user.

Sample Request

This sample REST API call uses the query resource to retrieve service appointments.

1https://yourInstance.salesforce.com/services/data/vXX.X/query/?q=SELECT+AppointmentNumber,
2+Id,+Status,+SchedStartTime,+SchedEndTime,+ServiceTerritoryId,+WorkTypeId+From+ServiceAppointment+WHERE+AccountId+=+'001B000001McLhMIAV'

For more information, see Execute a SOQL Query.

Sample Response

The method returns the available service appointments.

1{
2  "totalSize" : 5,
3  "done" : true,
4  "records" : [  {
5    "attributes" : {
6      "type" : "ServiceAppointment",
7      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKe4IAE"
8    },
9    "AppointmentNumber" : "SA-41906",
10    "Id" : "08pB0000000aKe4IAE",
11    "Status" : "Scheduled",
12    "SchedStartTime" : "2021-10-25T15:00:00.000+0000",
13    "SchedEndTime" : "2021-10-25T16:00:00.000+0000",
14    "ServiceTerritoryId" : "0HhB0000000TakhKAC",
15    "WorkTypeId" : null
16  },  {
17    "attributes" : {
18      "type" : "ServiceAppointment",
19      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKesIAE"
20    },
21    "AppointmentNumber" : "SA-41911",
22    "Id" : "08pB0000000aKesIAE",
23    "Status" : "Scheduled",
24    "SchedStartTime" : "2021-10-25T15:00:00.000+0000",
25    "SchedEndTime" : "2021-10-25T16:00:00.000+0000",
26    "ServiceTerritoryId" : "0HhB0000000TaHOKA0",
27    "WorkTypeId" : null
28  }, {
29    "attributes" : {
30      "type" : "ServiceAppointment",
31      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKexIAE"
32    },
33    "AppointmentNumber" : "SA-41912",
34    "Id" : "08pB0000000aKexIAE",
35    "Status" : "Scheduled",
36    "SchedStartTime" : "2021-10-22T16:30:00.000+0000",
37    "SchedEndTime" : "2021-10-22T18:00:00.000+0000",
38    "ServiceTerritoryId" : "0HhB0000000TakhKAC",
39    "WorkTypeId" : null
40  }, {
41    "attributes" : {
42      "type" : "ServiceAppointment",
43      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKf2IAE"
44    },
45    "AppointmentNumber" : "SA-41913",
46    "Id" : "08pB0000000aKf2IAE",
47    "Status" : "Scheduled",
48    "SchedStartTime" : "2021-10-25T17:30:00.000+0000",
49    "SchedEndTime" : "2021-10-25T18:30:00.000+0000",
50    "ServiceTerritoryId" : "0HhB0000000TaHOKA0",
51    "WorkTypeId" : "08qB0000000UF63IAG"
52  }, {
53    "attributes" : {
54      "type" : "ServiceAppointment",
55      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKf7IAE"
56    },
57    "AppointmentNumber" : "SA-41914",
58    "Id" : "08pB0000000aKf7IAE",
59    "Status" : "Scheduled",
60    "SchedStartTime" : "2021-10-22T15:00:00.000+0000",
61    "SchedEndTime" : "2021-10-22T15:45:00.000+0000",
62    "ServiceTerritoryId" : "0HhB0000000TakhKAC",
63    "WorkTypeId" : null
64  } ]
65}

Parse the JSON response, and display the service appointments on a page in your app so that users can select an appointment record to modify.

Here’s how that page can look.

A representation of the Select Service Appointment screen.

On the next page, you can provide users an option to select a service appointment to modify.