Get Product Recommendations Action

Retrieve a list of recommended products for a quote or order by using the Constraint Rule Engine.

This action is available in API version 67.0 and later.

Special Access Rules 

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

You can invoke this action via Apex and Flows only.

Inputs 

InputTypeDescription
additionalContextDataApex-definedAn array of Apex runtime_industries_cpq.AdditionalContextData records that contain the additional nodes used along with the context definition nodes for data hydration. The maximum number of supported nodes is 10.
additionalFieldsApex-definedAn Apex runtime_industries_cpq.AdditionalFields record that contains an array of additional standard or custom fields from the Product2 object to include in the response.
catalogIdstringID of the catalog from which to retrieve recommended products.
contextDefinitionstringAPI name of the context definition used for context creation. If you don’t specify a value, the context definition selected on the Product Discovery Settings page from Setup is used.
contextMappingstringAPI name of the context mapping used for data hydration. The value of this parameter is used only if it belongs to the specified context definition. If you don’t specify a value, the default context mapping of the context definition is used.
currencyCodestringCurrency code used for pricing calculations and product filtering.
enablePricingbooleanIndicates whether the pricing procedure must run (true) or not (false). For orgs where pricing is enabled, you can override to false to skip Salesforce Pricing execution. For orgs where pricing is disabled, you can’t override to true.
enableQualificationbooleanIndicates whether the qualification procedure must run (true) or not (false). For orgs where qualification is enabled, you can override to false to skip BRE qualification rules. For orgs where qualification is disabled, you can’t override to true.
filterCriteriaApex-definedA collection of Apex runtime_industries_cpq.FilterInputRepresentation records used to filter products. The filterCriteria parameter supports only the name property. The supported operators are eq, in, or contains. If this parameter contains multiple criteria, all criteria are applied using the and operator.
nextCursorstringA unique identifier that represents the position of the product from which the next set of results are retrieved.
pageSizeintegerMaximum number of recommended products to return in the response.
priceBookIdstringID of the pricebook from which to retrieve pricing details.
pricingProcedurestringAPI name of the pricing procedure used to calculate product prices. If you don’t specify a value, the pricing procedure selected on the Product Discovery Settings page from Setup is used.
qualificationProcedurestringAPI name of the qualification procedure used to evaluate product eligibility. If you don’t specify a value, the qualification procedure selected on the Product Discovery Settings page from Setup is used.
transactionContextIdstringContext ID of the transaction.
transactionIdstringID of the transaction.
usePromotionsbooleanIndicates whether to fetch promotions for recommended products (true) or not (false). Applies only when promotions are enabled for the org.
userContextApex-definedAn Apex ConnectApi.UserContextInputRepresentation record that contains the user details used to evaluate product eligibility and calculate prices.

Outputs 

OutputTypeDescription
errorMessagesApex-definedA list of Apex runtime_industries_cpq.ProductRecommendationErrorsOutputRepresentation records that contain error codes and messages returned by the action.
isSuccessfulbooleanIndicates whether the action call succeeded (true) or not (false).
nextCursorstringUnique identifier that represents the position of the next product in the dataset. Use this value as an input to retrieve the next page of results.
recommendedProductsApex-definedA list of Apex runtime_industries_cpq.RecommendedProductsOutputRepresentation records that contain the recommended products returned by the Constraint Rule Engine.
transactionContextIdstringContext ID of the transaction.

Example 

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

1Invocable.Action action = Invocable.Action.createStandardAction('getRecommendedProducts');
2action.setInvocationParameter('catalogId', '0ZSVW000000AhdB4AS');
3action.setInvocationParameter('transactionId', '0Q0VW0000018J6X0AU');
4List<Invocable.Action.Result> results = action.invoke();
5
6for (Invocable.Action.Result res : results) {
7    if (res.isSuccess()) {
8        Map<String, Object> outMap = res.getOutputParameters();
9        String jsonOutput = JSON.serialize(outMap);	
10        System.debug(jsonOutput);
11    }
12}

Here’s a sample response for the Get Product Recommendations action.

1{
2  "prodRecomErrorOutRepresentation": [],
3  "isSuccessful": true,
4  "productCursor": "MTAwMDAwMDAwNg==",
5  "transactionContextId": "0000000r25tq18g00291777531846434b162e02f878f425680e0d95dc5f650fe",
6  "recomProdOutputRepresentations": [
7    {
8      "status": null,
9      "qualificationContext": {
10        "reason": null,
11        "isQualified": true
12      },
13      "productType": null,
14      "productSpecificationType": null,
15      "productSellingModelOptions": [
16        {
17          "productSellingModelId": "0jPVW0000001fh32AA",
18          "productSellingModel": {
19            "status": "Active",
20            "sellingModelType": "TermDefined",
21            "pricingTermUnit": "Annual",
22            "pricingTerm": 1,
23            "name": "Term Annual",
24            "id": "0jPVW0000001fh32AA"
25          },
26          "productId": "01tVW000003l7txYAA",
27          "id": "0iOVW00000049w22AA"
28        },
29        {
30          "productSellingModelId": "0jPVW0000001fh52AA",
31          "productSellingModel": {
32            "status": "Active",
33            "sellingModelType": "Evergreen",
34            "pricingTermUnit": "Months",
35            "pricingTerm": 1,
36            "name": "Evergreen Monthly",
37            "id": "0jPVW0000001fh52AA"
38          },
39          "productId": "01tVW000003l7txYAA",
40          "id": "0iOVW00000049w12AA"
41        },
42        {
43          "productSellingModelId": "0jPVW0000001fh62AA",
44          "productSellingModel": {
45            "status": "Active",
46            "sellingModelType": "TermDefined",
47            "pricingTermUnit": "Months",
48            "pricingTerm": 1,
49            "name": "Term Monthly",
50            "id": "0jPVW0000001fh62AA"
51          },
52          "productId": "01tVW000003l7txYAA",
53          "id": "0iOVW00000049w32AA"
54        }
55      ],
56      "productQuantity": null,
57      "productCode": "QB-API",
58      "productClassification": {
59        "id": "11BVW000004ljiZ2AQ"
60      },
61      "prices": [
62        {
63          "pricingModel": {
64            "unitOfMeasure": null,
65            "pricingModelType": "TermDefined",
66            "occurrence": 1,
67            "name": "Term Annual",
68            "id": "0jPVW0000001fh32AA",
69            "frequency": "Annual"
70          },
71          "priceBookId": "01sVW0000024PZlYAM",
72          "priceBookEntryId": "01uVW000000jzfGYAQ",
73          "price": 15000,
74          "isSelected": false,
75          "isDerived": false,
76          "isDefault": true,
77          "effectiveTo": null,
78          "effectiveFrom": null,
79          "currencyIsoCode": "USD"
80        },
81        {
82          "pricingModel": {
83            "unitOfMeasure": null,
84            "pricingModelType": "Evergreen",
85            "occurrence": 1,
86            "name": "Evergreen Monthly",
87            "id": "0jPVW0000001fh52AA",
88            "frequency": "Months"
89          },
90          "priceBookId": "01sVW0000024PZlYAM",
91          "priceBookEntryId": "01uVW000000jzg8YAA",
92          "price": 2000,
93          "isSelected": false,
94          "isDerived": false,
95          "isDefault": false,
96          "effectiveTo": null,
97          "effectiveFrom": null,
98          "currencyIsoCode": "USD"
99        },
100        {
101          "pricingModel": {
102            "unitOfMeasure": null,
103            "pricingModelType": "TermDefined",
104            "occurrence": 1,
105            "name": "Term Monthly",
106            "id": "0jPVW0000001fh62AA",
107            "frequency": "Months"
108          },
109          "priceBookId": "01sVW0000024PZlYAM",
110          "priceBookEntryId": "01uVW000000jzg9YAA",
111          "price": 1500,
112          "isSelected": false,
113          "isDerived": false,
114          "isDefault": false,
115          "effectiveTo": null,
116          "effectiveFrom": null,
117          "currencyIsoCode": "USD"
118        }
119      ],
120      "nodeType": "simpleProduct",
121      "name": "Additional API",
122      "isSoldOnlyWithOtherProds": false,
123      "isQuantityEditable": null,
124      "isDefaultComponent": null,
125      "isComponentRequired": null,
126      "isAssetizable": true,
127      "isActive": true,
128      "id": "01tVW000003l7txYAA",
129      "endOfLifeDate": null,
130      "displayUrl": "/resource/add_api",
131      "discontinuedDate": null,
132      "description": null,
133      "configureDuringSale": "Allowed",
134      "configurationRules": [
135        {
136          "type": "recommend",
137          "details": [
138            {
139              "message": "APIAccessRequests recommends AdditionalAPI"
140            }
141          ]
142        },
143        {
144          "type": "disable",
145          "details": [
146            {
147              "message": "This is disabled"
148            }
149          ]
150        }
151      ],
152      "categories": [
153        {
154          "sortOrder": null,
155          "qualificationContext": {
156            "reason": null,
157            "isQualified": true
158          },
159          "parentCategoryId": null,
160          "name": "API",
161          "isNavigational": null,
162          "id": "0ZGVW000000IUEG4A4",
163          "hasSubCategories": null,
164          "description": null,
165          "childCategories": null,
166          "catalogId": "0ZSVW000000AhdB4AS"
167        }
168      ],
169      "catalogs": [
170        {
171          "status": null,
172          "numberOfCategories": 8,
173          "name": "QuantumBit Software",
174          "id": "0ZSVW000000AhdB4AS",
175          "effectiveStartDate": null,
176          "effectiveEndDate": null,
177          "description": null,
178          "customFields": [],
179          "catalogType": null,
180          "catalogCode": null
181        }
182      ],
183      "availabilityDate": null,
184      "additionalFields": []
185    }
186  ]
187}