Get Service Appointments Assigned to the Dummy Resource

Show your users the service appointments—appointments booked through Salesforce Scheduler—scheduled against the dummy resource by retrieving the list of service appointments. Branch managers or administrators can reassign the appointments to the actual resources.

For the list of AppointmentInvitation object fields, see ServiceAppointment.

  1. Create a page to show the service appointments scheduled against the dummy resource.

  2. To retrieve the list of service appointments, make a Query() request on the ServiceAppointment object.

    • To choose additional columns from the ServiceAppointment object, such as lead and parent record IDs, modify the query.
    • To see upcoming appointments first, sort appointments by start time ascending.
    • To avoid past appointments, add where currentTime is greater than start time.

    Sample REST API Request

    1https://YOUR_INSTANCE.salesforce.com//services/data/v68.0/query/?q=​SELECT+ServiceAppointmentId,ServiceResourceId,ServiceAppointment.SchedEndTime,ServiceAppointment.SchedStartTime,ServiceAppointment.ServiceTerritoryId,ServiceAppointment.Id+​FROM+AssignedResource+WHERE+ServiceResourceId+=+'0HnS70000004EFyKAM'+ORDER+BY+createdDate+DESC+limit+5

    Where YOUR_INSTANCE is a variable.

    Sample Response

    1{
    2  "totalSize": 5,
    3  "done": true,
    4  "records": [
    5    {
    6      "attributes": {
    7        "type": "AssignedResource",
    8        "url": "/services/data/v56.0/sobjects/AssignedResource/03rS70000000401IAA"
    9      },
    10      "ServiceAppointmentId": "08pS70000000CxOIAU",
    11      "ServiceResourceId": "0HnS70000004EFyKAM",
    12      "ServiceAppointment": {
    13        "attributes": {
    14          "type": "ServiceAppointment",
    15          "url": "/services/data/v56.0/sobjects/ServiceAppointment/08pS70000000CxOIAU"
    16        },
    17        "SchedEndTime": "2022-10-03T17:00:00.000+0000",
    18        "SchedStartTime": "2022-10-03T16:30:00.000+0000",
    19        "ServiceTerritoryId": "0HhS70000004F9zKAE",
    20        "Id": "08pS70000000CxOIAU"
    21      }
    22    },
    23    {
    24      "attributes": {
    25        "type": "AssignedResource",
    26        "url": "/services/data/v56.0/sobjects/AssignedResource/03rS700000003zwIAA"
    27      },
    28      "ServiceAppointmentId": "08pS70000000CxJIAU",
    29      "ServiceResourceId": "0HnS70000004EFyKAM",
    30      "ServiceAppointment": {
    31        "attributes": {
    32          "type": "ServiceAppointment",
    33          "url": "/services/data/v56.0/sobjects/ServiceAppointment/08pS70000000CxJIAU"
    34        },
    35        "SchedEndTime": "2022-10-03T17:00:00.000+0000",
    36        "SchedStartTime": "2022-10-03T16:30:00.000+0000",
    37        "ServiceTerritoryId": "0HhS70000004F9zKAE",
    38        "Id": "08pS70000000CxJIAU"
    39      }
    40    },
    41    {
    42      "attributes": {
    43        "type": "AssignedResource",
    44        "url": "/services/data/v56.0/sobjects/AssignedResource/03rS700000003zrIAA"
    45      },
    46      "ServiceAppointmentId": "08pS70000000CxEIAU",
    47      "ServiceResourceId": "0HnS70000004EFyKAM",
    48      "ServiceAppointment": {
    49        "attributes": {
    50          "type": "ServiceAppointment",
    51          "url": "/services/data/v56.0/sobjects/ServiceAppointment/08pS70000000CxEIAU"
    52        },
    53        "SchedEndTime": "2022-10-03T17:00:00.000+0000",
    54        "SchedStartTime": "2022-10-03T16:30:00.000+0000",
    55        "ServiceTerritoryId": "0HhS70000004F9zKAE",
    56        "Id": "08pS70000000CxEIAU"
    57      }
    58    },
    59    {
    60      "attributes": {
    61        "type": "AssignedResource",
    62        "url": "/services/data/v56.0/sobjects/AssignedResource/03rS70000004D3WIAU"
    63      },
    64      "ServiceAppointmentId": "08pS70000004F3xIAE",
    65      "ServiceResourceId": "0HnS70000004EFyKAM",
    66      "ServiceAppointment": {
    67        "attributes": {
    68          "type": "ServiceAppointment",
    69          "url": "/services/data/v56.0/sobjects/ServiceAppointment/08pS70000004F3xIAE"
    70        },
    71        "SchedEndTime": "2022-10-03T17:00:00.000+0000",
    72        "SchedStartTime": "2022-10-03T16:30:00.000+0000",
    73        "ServiceTerritoryId": "0HhS70000004F9zKAE",
    74        "Id": "08pS70000004F3xIAE"
    75      }
    76    },
    77    {
    78      "attributes": {
    79        "type": "AssignedResource",
    80        "url": "/services/data/v56.0/sobjects/AssignedResource/03rS700000003zmIAA"
    81      },
    82      "ServiceAppointmentId": "08pS70000000Cx9IAE",
    83      "ServiceResourceId": "0HnS70000004EFyKAM",
    84      "ServiceAppointment": {
    85        "attributes": {
    86          "type": "ServiceAppointment",
    87          "url": "/services/data/v56.0/sobjects/ServiceAppointment/08pS70000000Cx9IAE"
    88        },
    89        "SchedEndTime": "2022-10-03T17:00:00.000+0000",
    90        "SchedStartTime": "2022-10-03T16:30:00.000+0000",
    91        "ServiceTerritoryId": "0HhS70000004F9zKAE",
    92        "Id": "08pS70000000Cx9IAE"
    93      }
    94    }
    95  ]
    96}
  3. Parse the JSON response, and show the service appointments on a page that you created. Branch managers or administrators can reassign the appointments to the actual resources.