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.

https://yourInstance.salesforce.com/services/data/vXX.X/query/?q=SELECT+AppointmentNumber,
+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.

{
  "totalSize" : 5,
  "done" : true,
  "records" : [  {
    "attributes" : {
      "type" : "ServiceAppointment",
      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKe4IAE"
    },
    "AppointmentNumber" : "SA-41906",
    "Id" : "08pB0000000aKe4IAE",
    "Status" : "Scheduled",
    "SchedStartTime" : "2021-10-25T15:00:00.000+0000",
    "SchedEndTime" : "2021-10-25T16:00:00.000+0000",
    "ServiceTerritoryId" : "0HhB0000000TakhKAC",
    "WorkTypeId" : null
  },  {
    "attributes" : {
      "type" : "ServiceAppointment",
      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKesIAE"
    },
    "AppointmentNumber" : "SA-41911",
    "Id" : "08pB0000000aKesIAE",
    "Status" : "Scheduled",
    "SchedStartTime" : "2021-10-25T15:00:00.000+0000",
    "SchedEndTime" : "2021-10-25T16:00:00.000+0000",
    "ServiceTerritoryId" : "0HhB0000000TaHOKA0",
    "WorkTypeId" : null
  }, {
    "attributes" : {
      "type" : "ServiceAppointment",
      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKexIAE"
    },
    "AppointmentNumber" : "SA-41912",
    "Id" : "08pB0000000aKexIAE",
    "Status" : "Scheduled",
    "SchedStartTime" : "2021-10-22T16:30:00.000+0000",
    "SchedEndTime" : "2021-10-22T18:00:00.000+0000",
    "ServiceTerritoryId" : "0HhB0000000TakhKAC",
    "WorkTypeId" : null
  }, {
    "attributes" : {
      "type" : "ServiceAppointment",
      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKf2IAE"
    },
    "AppointmentNumber" : "SA-41913",
    "Id" : "08pB0000000aKf2IAE",
    "Status" : "Scheduled",
    "SchedStartTime" : "2021-10-25T17:30:00.000+0000",
    "SchedEndTime" : "2021-10-25T18:30:00.000+0000",
    "ServiceTerritoryId" : "0HhB0000000TaHOKA0",
    "WorkTypeId" : "08qB0000000UF63IAG"
  }, {
    "attributes" : {
      "type" : "ServiceAppointment",
      "url" : "/services/data/v53.0/sobjects/ServiceAppointment/08pB0000000aKf7IAE"
    },
    "AppointmentNumber" : "SA-41914",
    "Id" : "08pB0000000aKf7IAE",
    "Status" : "Scheduled",
    "SchedStartTime" : "2021-10-22T15:00:00.000+0000",
    "SchedEndTime" : "2021-10-22T15:45:00.000+0000",
    "ServiceTerritoryId" : "0HhB0000000TakhKAC",
    "WorkTypeId" : null
  } ]
}

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.