Get Categories Action

Get the list of categories associated with a catalog record.

This action is available in API version 64.0 and later.

You can invoke this action via Apex and Flows only.

Special Access Rules 

The Get Categories action is available in Enterprise, Unlimited, and Developer Editions where Product Discovery is enabled.

Inputs 

InputTypeDescription
additionalContextDataApex-definedCollection of Apex runtime_industries_cpq.AdditionalContextData records that contain additional context data for nodes of the custom context definition, if applicable. You can add details for up to 10 nodes.
catalogIdstringRequired. ID of the catalog record.
categoryNestLevelintegerLevel of nesting within the category hierarchy to include in the request.
contextDefinitionNamestringName of the custom context definition that’s used to create context data for categories. If null, the default context definition is used.
correlationIdstringUnique identifier attached to requests and messages, allowing reference to a specific transaction or event chain.
contextMappingNamestringName of the context mapping. By default, the default context mapping associated with the context definition is used.
enableQualificationProcedurebooleanIndicates whether qualification rules are applied to categories ( true ) or not ( false ).
filterInputRepresentationApex-definedCollection of Apex runtime_industries_cpq.FilterInputRepresentation records that contain the filter criteria applied to the category records.
parentCategoryIdstringID of the parent category record.
qualificationProcedureNamestringName of the custom qualification procedure that’s executed to determine the category list. If null, the default qualification procedure is executed.
userContextInputRepresentationApex-definedAn Apex UserContextInputRepresentation record that contains user details, such as account ID, geographical location, language preferences, and more.

Outputs 

OutputTypeDescription
apiStatusOutputRepresentationApex-definedAn Apex runtime_industries_cpq.ApiStatusRepresentation record that contains the status of the request, including the status code and message.
correlationIdstringUnique identifier attached to requests and messages, allowing reference to a specific transaction or event chain.
resultCategoryListApex-definedList of filtered category records. See CategoryOutputRepresentation.
resultListCountintegerNumber of category records in the result.

Example 

Here’s a sample input to call this invocable action from Apex code.

1Invocable.Action action = Invocable.Action.createStandardAction('getCategories');
2
3ConnectApi.UserContextInputRepresentation userContext = new ConnectApi.UserContextInputRepresentation();
4userContext.accountId = '001xx000003GYiEAAW';
5
6runtime_industries_cpq.ContextDataInput data = new runtime_industries_cpq.ContextDataInput();
7String nodeNameVal = 'Quote__c';
8Map<String,Object> nodeDataVal = new Map<String,Object>();
9nodeDataVal.put('id',(Object)'0Q0xx0000004CDsCAM');
10nodeDataVal.put('businessObjectType',(Object)'Quote');
11data.nodeName = nodeNameVal;
12data.nodeData = nodeDataVal;
13List<runtime_industries_cpq.ContextDataInput> contextData= new List<runtime_industries_cpq.ContextDataInput>();
14contextData.add(data);
15runtime_industries_cpq.AdditionalContextData additionalContextDataOut = new runtime_industries_cpq.AdditionalContextData();
16additionalContextDataOut.additionalContextData = new List<runtime_industries_cpq.ContextDataInput>();
17additionalContextDataOut.additionalContextData.add(data);
18
19action.setInvocationParameter('catalogId', '0ZSxx0000000002GAA');
20action.setInvocationParameter('correlationId', '9cbb9650-48c5-11ed-96d1-0afcf185843b');
21action.setInvocationParameter('userContextInputRepresentation', userContext);
22action.setInvocationParameter('enableQualificationProcedure', True);
23action.setInvocationParameter('qualificationProcedureName', 'CatQual02');
24action.setInvocationParameter('contextDefinitionName', 'CategoryCD');
25action.setInvocationParameter('contextMappingName', 'ProductDiscoveryMapping');
26action.setInvocationParameter('additionalContextData', additionalContextDataOut);
27//action.setInvocationParameter('categoryDepth', 4);
28//action.setInvocationParameter('parentCategoryId', '0ZGxx0000000001GAA');
29
30List<Invocable.Action.Result> results = action.invoke();
31System.debug('Search Action + '+results);

Here’s a sample response when you call this action.

1[
2  {
3    "actionName": "getCategories",
4    "errors": null,
5    "invocationId": null,
6    "isSuccess": true,
7    "outcome": null,
8    "outputValues": {
9      "resultCategoryList": [
10        {
11          "sortOrder": null,
12          "qualificationContext": {
13            "reason": "Category is not qualified because one or more field(s) do not match the qualification criteria. Fields:- CategoryId - 0ZGxx0000000001GAA quotename - null Max_Number_of_Employees - 1500 Min_Number_of_Employees - 1500",
14            "isQualified": false
15          },
16          "parentCategoryId": null,
17          "name": "Laptops",
18          "isNavigational": true,
19          "id": "0ZGxx0000000001GAA",
20          "hasSubCategories": true,
21          "description": null,
22          "childCategories": [],
23          "catalogId": "0ZSxx0000000002GAA"
24        },
25        {
26          "sortOrder": null,
27          "qualificationContext": {
28            "reason": null,
29            "isQualified": true
30          },
31          "parentCategoryId": null,
32          "name": "Desktops",
33          "isNavigational": true,
34          "id": "0ZGxx0000000002GAA",
35          "hasSubCategories": false,
36          "description": null,
37          "childCategories": [],
38          "catalogId": "0ZSxx0000000002GAA"
39        },
40        {
41          "sortOrder": null,
42          "qualificationContext": {
43            "reason": null,
44            "isQualified": true
45          },
46          "parentCategoryId": null,
47          "name": "Accessories",
48          "isNavigational": true,
49          "id": "0ZGxx0000000003GAA",
50          "hasSubCategories": false,
51          "description": null,
52          "childCategories": [],
53          "catalogId": "0ZSxx0000000002GAA"
54        }
55      ],
56      "resultListCount": 3,
57      "apiStatusOutputRepresentation": {
58        "statusMessage": null,
59        "statusCode": "FetchedDetailsSuccessfully",
60        "messages": []
61      },
62      "correlationId": "9cbb9650-48c5-11ed-96d1-0afcf185843b"
63    },
64    "sortOrder": -1,
65    "version": 1
66  }
67]