Create Service Appointments

The last step in the 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.

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

    Resource URI

    1https://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.

    1{
    2  "serviceAppointment": {
    3    "serviceTerritoryId": "0Hhx000000012oSCAQ",
    4    "parentRecordId": "001x0000005DLxpAAG",
    5    "workTypeId": "08qx000000014fnAAA",
    6    "schedStartTime": "2022-04-19T10:30:00.000+0000",
    7    "schedEndTime": "2022-04-19T10:40:00.000+0000",
    8    "additionalInformation": "Appointment Scheduling Custom App.",
    9    "appointmentType": "Testing Purpose",
    10    "extendedFields": [
    11      {
    12        "name": "status",
    13        "value": "Scheduled"
    14      }
    15    ]
    16  },
    17  "assignedResources": [
    18    {
    19      "serviceResourceId": "0Hnx000000006GcCAI",
    20      "isRequiredResource": "true"
    21    }
    22  ]
    23}

    Sample Response

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

    1{
    2  "result": {
    3    "assignedResourceIds": [
    4      "03rx00000001uxJAAQ"
    5    ],
    6    "serviceAppointmentId": "08px00000001toRAAQ"
    7  }
    8}

    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.

    1{
    2  "serviceAppointment": {
    3    "serviceTerritoryId": "0Hhx000000012oSCAQ",
    4    "workTypeId": "08qx000000014fnAAA",
    5    "schedStartTime": "2022-04-19T10:30:00.000+0000",
    6    "schedEndTime": "2022-04-19T10:40:00.000+0000",
    7    "additionalInformation": "Appointment Scheduling Custom App.",
    8    "appointmentType": "Testing Purpose",
    9    "extendedFields": [
    10      {
    11        "name": "status",
    12        "value": "Scheduled"
    13      }
    14    ]
    15  },
    16  "assignedResources": [
    17    {
    18      "serviceResourceId": "0Hnx000000006H4CAI",
    19      "isRequiredResource": "true"
    20    }
    21  ],
    22  "lead": {
    23    "email": "name@company.com",
    24    "firstName": "FName",
    25    "lastName": "LName",
    26    "company": "CompanyName"
    27  }
    28}

    Sample Response

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

    1{
    2  "result": {
    3    "assignedResourceIds": [
    4      "03rx00000001uxOAAQ"
    5    ],
    6    "parentRecordId": "00Qx0000001cKPoEAM",
    7    "serviceAppointmentId": "08px00000001toWAAQ"
    8  }
    9}

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.