Get Work Type Groups

Display the work type groups for the appointment.

A work type group represents a general appointment category or topic, such as a home loan or investment.

Create a page in your app where you can show the work type groups from your org.

  1. Use the Query() request on the ServiceTerritoryWorkType object to retrieve the work types associated with the service territory selected on the Select Service Territory screen.

    Sample Request

    This sample REST API call uses the Query() request to retrieve the work type records.

    For more information on using Query() request, see Execute a SOQL Query.

    1https://YOUR_INSTANCE.salesforce.com/services/data/vXX.X/query/?q=
    2SELECT+Id,WorkTypeId,WorkType.Name+FROM+ServiceTerritoryWorkType+WHERE+ServiceTerritoryId+=+'0Hhx000000012oSCAQ'

    Where YOUR_INSTANCE is a variable.

    Sample Response

    The request returns the work type records.

    1{
    2  "totalSize": 2,
    3  "done": true,
    4  "records": [
    5    {
    6      "attributes": {
    7        "type": "ServiceTerritoryWorkType",
    8        "url": "/services/data/v55.0/sobjects/ServiceTerritoryWorkType/0VEx00000001CTGGA2"
    9      },
    10      "Id": "0VEx00000001CTGGA2",
    11      "WorkTypeId": "08qx000000014fvAAA",
    12      "WorkType": {
    13        "attributes": {
    14          "type": "WorkType",
    15          "url": "/services/data/v55.0/sobjects/WorkType/08qx000000014fvAAA"
    16        },
    17        "Name": "WT 2"
    18      }
    19    },
    20    {
    21      "attributes": {
    22        "type": "ServiceTerritoryWorkType",
    23        "url": "/services/data/v55.0/sobjects/ServiceTerritoryWorkType/0VEx00000001Ag4GAE"
    24      },
    25      "Id": "0VEx00000001Ag4GAE",
    26      "WorkTypeId": "08qx000000014fnAAA",
    27      "WorkType": {
    28        "attributes": {
    29          "type": "WorkType",
    30          "url": "/services/data/v55.0/sobjects/WorkType/08qx000000014fnAAA"
    31        },
    32        "Name": "WT 3"
    33      }
    34    }
    35  ]
    36}
  2. Use the Query() request on the WorkTypeGroupMember object to retrieve the work type groups by work types retrieved in the previous step.

    Sample Request

    This sample REST API call uses the Query() request to retrieve work type groups.

    For more information on using Query() request, see Execute a SOQL Query.

    1https://YOUR_INSTANCE.salesforce.com/services/data/vXX.X/query/?q=
    2SELECT Id,WorkTypeGroupId,WorkTypeId,WorkTypeGroup.Name FROM WorkTypeGroupMember WHERE WorkTypeId in ('08qx000000014fnAAA','08qx000000014fvAAA')

    Where YOUR_INSTANCE is a variable.

    You can use the toLabel method to translate the SOQL query results in the language of the user. For more information, see Translate SOQL Query Results.

    Note

    Sample Response

    The request returns the work type group records.

    1{
    2  "totalSize": 2,
    3  "done": true,
    4  "records": [
    5    {
    6      "attributes": {
    7        "type": "WorkTypeGroupMember",
    8        "url": "/services/data/v55.0/sobjects/WorkTypeGroupMember/0Wzx000000013tICAQ"
    9      },
    10      "Id": "0Wzx000000013tICAQ",
    11      "WorkTypeGroupId": "0VSx000000014DmGAI",
    12      "WorkTypeId": "08qx000000014fnAAA",
    13      "WorkTypeGroup": {
    14        "attributes": {
    15          "type": "WorkTypeGroup",
    16          "url": "/services/data/v55.0/sobjects/WorkTypeGroup/0VSx000000014DmGAI"
    17        },
    18        "Name": "WTG 2"
    19      }
    20    },
    21    {
    22      "attributes": {
    23        "type": "WorkTypeGroupMember",
    24        "url": "/services/data/v55.0/sobjects/WorkTypeGroupMember/0Wzx000000013tHCAQ"
    25      },
    26      "Id": "0Wzx000000013tHCAQ",
    27      "WorkTypeGroupId": "0VSx000000014DkGAI",
    28      "WorkTypeId": "08qx000000014fvAAA",
    29      "WorkTypeGroup": {
    30        "attributes": {
    31          "type": "WorkTypeGroup",
    32          "url": "/services/data/v55.0/sobjects/WorkTypeGroup/0VSx000000014DkGAI"
    33        },
    34        "Name": "WTG 1"
    35      }
    36    }
    37  ]
    38}

    Parse the JSON response, and display the work type groups on web page so that users can select a work type group for the appointment. Here’s how that page can look.

    A representation of the Select Work Type Group screen.

Default to the work type that is associated with the service territory selected on the Select Service Territory screen and the work type group selected on the Select Work Type Group screen.