Create Service Appointments

The last step in the concurrent scheduling application is to show the service appointment details for the user to review and create the appointment. A service appointment represents an appointment booked through Salesforce Scheduler.

Create a page where the user can review the appointment details and create the appointment. Here’s how a Review Service Appointment page can look.

A representation of the Review Service Appointment screen.

Link the Next button to a POST request on the service-appointments Connect API to create the service appointment.

Resource URI

https://yourInstance.salesforce.com/services/data/vXX.X/connect/scheduling/service-appointments

For an Existing User (Account)

Sample Request

Pass the account ID as parentRecordId in the input request body.

Set status to Scheduled to indicate that the appointment is scheduled.

{
   "serviceAppointment": {
      "serviceTerritoryId": "0HhB00000001P0PKAU",
      "parentRecordId" : "001B0000018vs9fIAA",
      "workTypeId" : "08qB00000002ocgIAA",
      "schedStartTime" : "2021-10-29T16:00:00.000+0000",
      "schedEndTime": "2021-10-29T17:00:00.000+0000",
      "additionalInformation" : "Concurrent Booking",
      "appointmentType" : "Training Purpose",
      "extendedFields" : [ {
        "name": "status",
        "value": "Scheduled"
     } ]
   },
   "assignedResources": [
      {
      "serviceResourceId": "0HnB00000001SJxKAM",
      "isRequiredResource" : "true"
      }
   ]
}

Sample Response

The API returns the service appointment ID and the assigned service resources.

{
  "result" : {
    "assignedResourceIds" : [ "03rB0000000cBZ6IAM" ],
    "serviceAppointmentId" : "08pB0000000aKjMIAU"
  }
}

For a Guest User (Lead)

Sample Request

Pass the required lead details in the input request body.

Set status to Scheduled to indicate that the appointment is scheduled.

{
   "serviceAppointment": {
      "serviceTerritoryId": "0HhB00000001P0PKAU",
      "schedStartTime" : "2021-10-29T16:00:00.000+0000",
      "schedEndTime": "2021-10-29T17:00:00.000+0000",
      "workTypeId" : "08qB00000002ocgIAA",
      "additionalInformation" : "Concurrent Booking",
      "appointmentType" : "Training Purpose",
      "extendedFields" : [ {
        "name": "status",
        "value": "Scheduled"
     } ]
   },
   "assignedResources": [
      {
      "serviceResourceId": "0HnB00000001SJxKAM",
      "isRequiredResource" : "true"
      }
   ],
   "lead": {
      "email" : "name@company.com",
      "firstName" : "FName",
      "lastName" : "LName",
      "company" : "CompanyName"
   }
}

Sample Response

The API returns the service appointment ID and the assigned service resources.

{
  "result" : {
    "assignedResourceIds" : [ "03rB0000000cBAFIA2" ],
    "parentRecordId" : "00QB000000ASSt5MAH",
    "serviceAppointmentId" : "08pB0000000aKIgIAM"
  }
}

Create a page to show confirmation when the service appointment is created successfully.

Here’s how a sample confirmation page can look.

A representation of the confirmation screen.