# 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](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm).

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

   Where `YOUR_INSTANCE` is a variable.

   **Sample Response**

   The request returns the work type records.

   ```nolang
   {
     "totalSize": 2,
     "done": true,
     "records": [
       {
         "attributes": {
           "type": "ServiceTerritoryWorkType",
           "url": "/services/data/v55.0/sobjects/ServiceTerritoryWorkType/0VEx00000001CTGGA2"
         },
         "Id": "0VEx00000001CTGGA2",
         "WorkTypeId": "08qx000000014fvAAA",
         "WorkType": {
           "attributes": {
             "type": "WorkType",
             "url": "/services/data/v55.0/sobjects/WorkType/08qx000000014fvAAA"
           },
           "Name": "WT 2"
         }
       },
       {
         "attributes": {
           "type": "ServiceTerritoryWorkType",
           "url": "/services/data/v55.0/sobjects/ServiceTerritoryWorkType/0VEx00000001Ag4GAE"
         },
         "Id": "0VEx00000001Ag4GAE",
         "WorkTypeId": "08qx000000014fnAAA",
         "WorkType": {
           "attributes": {
             "type": "WorkType",
             "url": "/services/data/v55.0/sobjects/WorkType/08qx000000014fnAAA"
           },
           "Name": "WT 3"
         }
       }
     ]
   }
   ```

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](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm).

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

   Where `YOUR_INSTANCE` is a variable.

   :::note
   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](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_tolabel.htm).
   :::

   **Sample Response**

   The request returns the work type group records.

   ```nolang
   {
     "totalSize": 2,
     "done": true,
     "records": [
       {
         "attributes": {
           "type": "WorkTypeGroupMember",
           "url": "/services/data/v55.0/sobjects/WorkTypeGroupMember/0Wzx000000013tICAQ"
         },
         "Id": "0Wzx000000013tICAQ",
         "WorkTypeGroupId": "0VSx000000014DmGAI",
         "WorkTypeId": "08qx000000014fnAAA",
         "WorkTypeGroup": {
           "attributes": {
             "type": "WorkTypeGroup",
             "url": "/services/data/v55.0/sobjects/WorkTypeGroup/0VSx000000014DmGAI"
           },
           "Name": "WTG 2"
         }
       },
       {
         "attributes": {
           "type": "WorkTypeGroupMember",
           "url": "/services/data/v55.0/sobjects/WorkTypeGroupMember/0Wzx000000013tHCAQ"
         },
         "Id": "0Wzx000000013tHCAQ",
         "WorkTypeGroupId": "0VSx000000014DkGAI",
         "WorkTypeId": "08qx000000014fvAAA",
         "WorkTypeGroup": {
           "attributes": {
             "type": "WorkTypeGroup",
             "url": "/services/data/v55.0/sobjects/WorkTypeGroup/0VSx000000014DkGAI"
           },
           "Name": "WTG 1"
         }
       }
     ]
   }
   ```

   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.](https://a.sfdcstatic.com/developer-website/sfdocs/service-cloud/media/salesforce-scheduler-dev-guide/uc9\_work_type_groups.png)

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.
