Find Products Action

Search for the products from a catalog, category, or subcategory by using the specified search term.

This action is available in API version 62.0 and later.

Special Access Rules 

The Find Products 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 that are 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 to include in the response. The supported objects are Product2 or ProductAttributeDefinition—If the fields defined for the ProductAttributeDefinition object aren’t available for the ProductClassificationAttr object, then the API request fails.
catalogIdstringCatalog ID that’s used to find and retrieve the products.
categoryIdstringID of the category or subcategory to get the products for.
contextDefinitionstringAPI name of the context definition used for context creation. If you don’t specify a value, the context selected on the Product Discovery Settings page from Setup is used.
contextMappingstringAPI name of the context mapping that’s used for data hydration. The value of this parameter is used only if it belongs to the specified context definition.
correlationIdstringCurrency code that’s used to calculate and show prices. Only the products with the currency code matching the specified currency code are fetched.
currencyCodestringCurrency code that’s used to calculate and show prices.
cursorstringA unique identifier that represents the position of the product from which the next set of results are retrieved.
executeConfigurationRulesbooleanIndicates whether configuration rules must run (true) or not (false). Available in API version 67.0 and later.
enablePricingbooleanIndicates whether the pricing procedure must run (true) or not (false). The default value is true. To use this parameter, you must enable the Pricing Procedure setting from Setup.
enableQualificationbooleanIndicates whether the qualification procedure must run (true) or not (false). The default value is true. To use this parameter, you must enable the Qualification Procedure setting from Setup.
filterApex-definedA collection of Apex runtime_industries_cpq.FilterInputRepresentation records where each record contains a related object and the filter criteria that’s applied on the object. The filter parameter supports only the name property. The supported operators are eq, in, or contains. If this parameter contains multiple criteria, all the criteria are applied.
includeCatalogDetailsbooleanIndicates whether catalog details must be included in the response (true) or not (false).
limitintegerMaximum number of results to be returned in the response. Enter a value from 1 through 100. The default value is 10.
orderBystringComma-separated string of key-value pairs that specify how results are sorted. Each string must contain a field name and its sort order. For example, ["name:asc",”custom_field:asc”].
priceBookIdstringID of the pricebook from which you wan to retrieve the pricing details.
productClassificationIdstringID of the product classification that’s used to filter products.
pricingProcedurestringAPI name of the pricing procedure 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 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 quote or order. Available in API version 67.0 and later.
transactionIdstringID of the quote or order. Available in API version 67.0 and later.
relatedObjectFiltersApex-definedA collection of Apex runtime_industries_cpq.RelatedObjectFilterInputRepresentation records, where each record contains a related object and the filter criteria that’s applied on the object.
searchTermstringRequired. Search term to find and retrieve products.
userContextApex-definedAn Apex ConnectApi.UserContextInputRepresentation record that contains the user details to evaluate product eligibility and calculate prices.

Outputs 

OutputTypeDescription
apiStatusApex-definedAn Apex runtime_industries_cpq.ApiStatusRepresentation record that contains a status code and message.
contextIdstringID of the context that’s created by using the specified context definition.
correlationIdstringID to reference a series of related actions.
cursorstringUnique identifier that represents the position of the next product in the dataset. It’s used as an input to retrieve the next set of products.
facetsApex-definedCollection of Apex ProductFacetsRepresentation records that contain details of the facet that’s retrieved.
resultsApex-definedAn Apex runtime_industries_cpq.SearchProductsRepresentation record that contains the products that match the query.
userContextApex-definedAn Apex ConnectApi.UserContextRepresentation record that includes the user details.

Example 

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

1Invocable.Action action = Invocable.Action.createStandardAction('findProducts');
2action.setInvocationParameter('searchTerm', 'Additional API');
3action.setInvocationParameter('executeConfigurationRules', true);
4action.setInvocationParameter('catalogId', '0ZSVW000000AhdB4AS');
5action.setInvocationParameter('transactionId', '0Q0VW0000018J6X0AU');
6List<String> orderBy = new List<String>();
7orderBy.add('name:asc');
8action.setInvocationParameter('orderBy', orderBy);
9List<Invocable.Action.Result> results = action.invoke();
10
11for (Invocable.Action.Result res : results) {
12    if (res.isSuccess()) {
13        Map<String, Object> outMap = res.getOutputParameters();
14        String jsonOutput = JSON.serialize(outMap);	
15        System.debug(jsonOutput);
16    }
17}

Here’s a sample response for this action.

1{
2  "facets": [],
3  "apiStatus": {
4    "statusMessage": null,
5    "statusCode": "FetchedDetailsSuccessfully",
6    "messages": []
7  },
8  "results": [
9    {
10      "unitOfMeasure": null,
11      "status": null,
12      "qualificationContext": {
13        "reason": null,
14        "isQualified": true
15      },
16      "productType": null,
17      "productSpecificationType": null,
18      "productSellingModelOptions": [
19        {
20          "productSellingModelId": "0jPVW0000001fh32AA",
21          "productSellingModel": {
22            "status": "Active",
23            "sellingModelType": "TermDefined",
24            "pricingTermUnit": "Annual",
25            "pricingTerm": 1,
26            "name": "Term Annual",
27            "id": "0jPVW0000001fh32AA"
28          },
29          "productId": "01tVW000003l7txYAA",
30          "id": "0iOVW00000049w22AA"
31        },
32        {
33          "productSellingModelId": "0jPVW0000001fh52AA",
34          "productSellingModel": {
35            "status": "Active",
36            "sellingModelType": "Evergreen",
37            "pricingTermUnit": "Months",
38            "pricingTerm": 1,
39            "name": "Evergreen Monthly",
40            "id": "0jPVW0000001fh52AA"
41          },
42          "productId": "01tVW000003l7txYAA",
43          "id": "0iOVW00000049w12AA"
44        },
45        {
46          "productSellingModelId": "0jPVW0000001fh62AA",
47          "productSellingModel": {
48            "status": "Active",
49            "sellingModelType": "TermDefined",
50            "pricingTermUnit": "Months",
51            "pricingTerm": 1,
52            "name": "Term Monthly",
53            "id": "0jPVW0000001fh62AA"
54          },
55          "productId": "01tVW000003l7txYAA",
56          "id": "0iOVW00000049w32AA"
57        }
58      ],
59      "productRelatedComponent": null,
60      "productQuantity": null,
61      "productPricingInformation": null,
62      "productInformation": null,
63      "productComponentGroups": [],
64      "productCode": "QB-API",
65      "productClassification": {
66        "id": "11BVW000004ljiZ2AQ"
67      },
68      "prices": [
69        {
70          "pricingModel": {
71            "unitOfMeasure": null,
72            "pricingModelType": "TermDefined",
73            "occurrence": 1,
74            "name": "Term Annual",
75            "id": "0jPVW0000001fh32AA",
76            "frequency": "Annual"
77          },
78          "priceBookId": "01sVW0000024PZlYAM",
79          "priceBookEntryId": "01uVW000000jzfGYAQ",
80          "price": 15000,
81          "isSelected": false,
82          "isDerived": false,
83          "isDefault": true,
84          "effectiveTo": null,
85          "effectiveFrom": null,
86          "currencyIsoCode": "USD"
87        },
88        {
89          "pricingModel": {
90            "unitOfMeasure": null,
91            "pricingModelType": "Evergreen",
92            "occurrence": 1,
93            "name": "Evergreen Monthly",
94            "id": "0jPVW0000001fh52AA",
95            "frequency": "Months"
96          },
97          "priceBookId": "01sVW0000024PZlYAM",
98          "priceBookEntryId": "01uVW000000jzg8YAA",
99          "price": 2000,
100          "isSelected": false,
101          "isDerived": false,
102          "isDefault": false,
103          "effectiveTo": null,
104          "effectiveFrom": null,
105          "currencyIsoCode": "USD"
106        },
107        {
108          "pricingModel": {
109            "unitOfMeasure": null,
110            "pricingModelType": "TermDefined",
111            "occurrence": 1,
112            "name": "Term Monthly",
113            "id": "0jPVW0000001fh62AA",
114            "frequency": "Months"
115          },
116          "priceBookId": "01sVW0000024PZlYAM",
117          "priceBookEntryId": "01uVW000000jzg9YAA",
118          "price": 1500,
119          "isSelected": false,
120          "isDerived": false,
121          "isDefault": false,
122          "effectiveTo": null,
123          "effectiveFrom": null,
124          "currencyIsoCode": "USD"
125        }
126      ],
127      "nodeType": "simpleProduct",
128      "name": "Additional API",
129      "isSoldOnlyWithOtherProds": false,
130      "isQuantityEditable": null,
131      "isDefaultComponent": null,
132      "isComponentRequired": null,
133      "isAssetizable": true,
134      "isActive": true,
135      "id": "01tVW000003l7txYAA",
136      "endOfLifeDate": null,
137      "displayUrl": "/resource/add_api",
138      "discontinuedDate": null,
139      "description": null,
140      "configureDuringSale": "Allowed",
141      "configurationRules": [
142        {
143          "type": "disable",
144          "details": [
145            {
146              "message": "This is disabled"
147            }
148          ]
149        }
150      ],
151      "catalogs": [],
152      "availabilityDate": null,
153      "attributeCategories": [],
154      "additionalFields": []
155    },
156    {
157      "unitOfMeasure": null,
158      "status": null,
159      "qualificationContext": {
160        "reason": null,
161        "isQualified": true
162      },
163      "productType": null,
164      "productSpecificationType": null,
165      "productSellingModelOptions": [
166        {
167          "productSellingModelId": "0jPVW0000001fh32AA",
168          "productSellingModel": {
169            "status": "Active",
170            "sellingModelType": "TermDefined",
171            "pricingTermUnit": "Annual",
172            "pricingTerm": 1,
173            "name": "Term Annual",
174            "id": "0jPVW0000001fh32AA"
175          },
176          "productId": "01tVW000003l7tyYAA",
177          "id": "0iOVW00000049w42AA"
178        }
179      ],
180      "productRelatedComponent": null,
181      "productQuantity": null,
182      "productPricingInformation": null,
183      "productInformation": null,
184      "productComponentGroups": [],
185      "productCode": "QB-API-FLEX",
186      "productClassification": {
187        "id": null
188      },
189      "prices": [
190        {
191          "pricingModel": {
192            "unitOfMeasure": null,
193            "pricingModelType": "TermDefined",
194            "occurrence": 1,
195            "name": "Term Annual",
196            "id": "0jPVW0000001fh32AA",
197            "frequency": "Annual"
198          },
199          "priceBookId": "01sVW0000024PZlYAM",
200          "priceBookEntryId": "01uVW000000jzfFYAQ",
201          "price": 450,
202          "isSelected": false,
203          "isDerived": false,
204          "isDefault": true,
205          "effectiveTo": null,
206          "effectiveFrom": null,
207          "currencyIsoCode": "USD"
208        }
209      ],
210      "nodeType": "simpleProduct",
211      "name": "Additional API Flex (100M)",
212      "isSoldOnlyWithOtherProds": false,
213      "isQuantityEditable": null,
214      "isDefaultComponent": null,
215      "isComponentRequired": null,
216      "isAssetizable": true,
217      "isActive": true,
218      "id": "01tVW000003l7tyYAA",
219      "endOfLifeDate": null,
220      "displayUrl": "/resource/api_flex",
221      "discontinuedDate": null,
222      "description": "API instances remain under management until they are deleted. Instances of API Manager are aggregated using a Max Concurrent model. The usage for a month is the highest number of APIs Managed in a single given hour during a month.",
223      "configureDuringSale": null,
224      "configurationRules": [],
225      "catalogs": [],
226      "availabilityDate": null,
227      "attributeCategories": [],
228      "additionalFields": []
229    },
230    {
231      "unitOfMeasure": null,
232      "status": null,
233      "qualificationContext": {
234        "reason": null,
235        "isQualified": true
236      },
237      "productType": null,
238      "productSpecificationType": null,
239      "productSellingModelOptions": [
240        {
241          "productSellingModelId": "0jPVW0000001fh32AA",
242          "productSellingModel": {
243            "status": "Active",
244            "sellingModelType": "TermDefined",
245            "pricingTermUnit": "Annual",
246            "pricingTerm": 1,
247            "name": "Term Annual",
248            "id": "0jPVW0000001fh32AA"
249          },
250          "productId": "01tVW000003l7tzYAA",
251          "id": "0iOVW00000049w52AA"
252        }
253      ],
254      "productRelatedComponent": null,
255      "productQuantity": null,
256      "productPricingInformation": null,
257      "productInformation": null,
258      "productComponentGroups": [],
259      "productCode": "QB-API-GOVT",
260      "productClassification": {
261        "id": null
262      },
263      "prices": [
264        {
265          "pricingModel": {
266            "unitOfMeasure": null,
267            "pricingModelType": "TermDefined",
268            "occurrence": 1,
269            "name": "Term Annual",
270            "id": "0jPVW0000001fh32AA",
271            "frequency": "Annual"
272          },
273          "priceBookId": "01sVW0000024PZlYAM",
274          "priceBookEntryId": "01uVW000000jzfHYAQ",
275          "price": 1450,
276          "isSelected": false,
277          "isDerived": false,
278          "isDefault": true,
279          "effectiveTo": null,
280          "effectiveFrom": null,
281          "currencyIsoCode": "USD"
282        }
283      ],
284      "nodeType": "simpleProduct",
285      "name": "Additional API Gov",
286      "isSoldOnlyWithOtherProds": false,
287      "isQuantityEditable": null,
288      "isDefaultComponent": null,
289      "isComponentRequired": null,
290      "isAssetizable": true,
291      "isActive": true,
292      "id": "01tVW000003l7tzYAA",
293      "endOfLifeDate": null,
294      "displayUrl": "/resource/api_govt",
295      "discontinuedDate": null,
296      "description": "API instances remain under management until they are deleted. Instances of API Manager are aggregated using a Max Concurrent model. The usage for a month is the highest number of APIs Managed in a single given hour during a month.",
297      "configureDuringSale": null,
298      "configurationRules": [],
299      "catalogs": [],
300      "availabilityDate": null,
301      "attributeCategories": [],
302      "additionalFields": []
303    },
304    {
305      "unitOfMeasure": null,
306      "status": null,
307      "qualificationContext": {
308        "reason": null,
309        "isQualified": true
310      },
311      "productType": null,
312      "productSpecificationType": null,
313      "productSellingModelOptions": [
314        {
315          "productSellingModelId": "0jPVW0000001fh32AA",
316          "productSellingModel": {
317            "status": "Active",
318            "sellingModelType": "TermDefined",
319            "pricingTermUnit": "Annual",
320            "pricingTerm": 1,
321            "name": "Term Annual",
322            "id": "0jPVW0000001fh32AA"
323          },
324          "productId": "01tVW000003l7u0YAA",
325          "id": "0iOVW00000049w92AA"
326        }
327      ],
328      "productRelatedComponent": null,
329      "productQuantity": null,
330      "productPricingInformation": null,
331      "productInformation": null,
332      "productComponentGroups": [],
333      "productCode": "QB-API-PREP",
334      "productClassification": {
335        "id": null
336      },
337      "prices": [
338        {
339          "pricingModel": {
340            "unitOfMeasure": null,
341            "pricingModelType": "TermDefined",
342            "occurrence": 1,
343            "name": "Term Annual",
344            "id": "0jPVW0000001fh32AA",
345            "frequency": "Annual"
346          },
347          "priceBookId": "01sVW0000024PZlYAM",
348          "priceBookEntryId": "01uVW000000jzfSYAQ",
349          "price": 3240,
350          "isSelected": false,
351          "isDerived": false,
352          "isDefault": true,
353          "effectiveTo": null,
354          "effectiveFrom": null,
355          "currencyIsoCode": "USD"
356        }
357      ],
358      "nodeType": "simpleProduct",
359      "name": "Additional API Pre-Prod",
360      "isSoldOnlyWithOtherProds": false,
361      "isQuantityEditable": null,
362      "isDefaultComponent": null,
363      "isComponentRequired": null,
364      "isAssetizable": true,
365      "isActive": true,
366      "id": "01tVW000003l7u0YAA",
367      "endOfLifeDate": null,
368      "displayUrl": "/resource/api_preprod",
369      "discontinuedDate": null,
370      "description": "API instances remain under management until they are deleted. Instances of API Manager are aggregated using a Max Concurrent model. The usage for a month is the highest number of APIs Managed in a single given hour during a month.",
371      "configureDuringSale": null,
372      "configurationRules": [],
373      "catalogs": [],
374      "availabilityDate": null,
375      "attributeCategories": [],
376      "additionalFields": []
377    },
378    {
379      "unitOfMeasure": null,
380      "status": null,
381      "qualificationContext": {
382        "reason": null,
383        "isQualified": true
384      },
385      "productType": null,
386      "productSpecificationType": null,
387      "productSellingModelOptions": [
388        {
389          "productSellingModelId": "0jPVW0000001fh32AA",
390          "productSellingModel": {
391            "status": "Active",
392            "sellingModelType": "TermDefined",
393            "pricingTermUnit": "Annual",
394            "pricingTerm": 1,
395            "name": "Term Annual",
396            "id": "0jPVW0000001fh32AA"
397          },
398          "productId": "01tVW000003l7u1YAA",
399          "id": "0iOVW00000049wA2AQ"
400        }
401      ],
402      "productRelatedComponent": null,
403      "productQuantity": null,
404      "productPricingInformation": null,
405      "productInformation": null,
406      "productComponentGroups": [],
407      "productCode": "QB-API-PROD",
408      "productClassification": {
409        "id": null
410      },
411      "prices": [
412        {
413          "pricingModel": {
414            "unitOfMeasure": null,
415            "pricingModelType": "TermDefined",
416            "occurrence": 1,
417            "name": "Term Annual",
418            "id": "0jPVW0000001fh32AA",
419            "frequency": "Annual"
420          },
421          "priceBookId": "01sVW0000024PZlYAM",
422          "priceBookEntryId": "01uVW000000jzfdYAA",
423          "price": 3240,
424          "isSelected": false,
425          "isDerived": false,
426          "isDefault": true,
427          "effectiveTo": null,
428          "effectiveFrom": null,
429          "currencyIsoCode": "USD"
430        }
431      ],
432      "nodeType": "simpleProduct",
433      "name": "Additional API Prod",
434      "isSoldOnlyWithOtherProds": false,
435      "isQuantityEditable": null,
436      "isDefaultComponent": null,
437      "isComponentRequired": null,
438      "isAssetizable": true,
439      "isActive": true,
440      "id": "01tVW000003l7u1YAA",
441      "endOfLifeDate": null,
442      "displayUrl": "/resource/api_prod",
443      "discontinuedDate": null,
444      "description": "API instances remain under management until they are deleted. Instances of API Manager are aggregated using a Max Concurrent model. The usage for a month is the highest number of APIs Managed in a single given hour during a month.",
445      "configureDuringSale": null,
446      "configurationRules": [],
447      "catalogs": [],
448      "availabilityDate": null,
449      "attributeCategories": [],
450      "additionalFields": []
451    }
452  ],
453  "contextId": "0000000r25tp21g002517775323419202e0743b1f275423d8a489c12ca99da72",
454  "correlationId": "4ac34e38-13d6-4720-97c4-4db7b3d41678"
455}

Usage of an Apex-Defined Data Type in a Flow 

To use an Apex-defined input parameter in a flow, follow these guidelines.

Create an Apex Class

Create an Apex class defining the input and output parameters. In the flow, include the Apex-defined input parameters for which you want to add the details. In this example, we’ve created a class named ProductServiceAction that takes an object’s API name and record ID as input, and returns the additional context data.

1public class ProductServiceAction {
2    // Define input parameters
3    public class FlowInput{
4        @InvocableVariable(required=false)
5        public String objectApiName;
6        
7        @InvocableVariable(required=false)
8        public String recordId;
9    }
10    
11    // Define output parameters
12    public class FlowOutput{
13        @invocableVariable
14        public runtime_industries_cpq.AdditionalContextData additionalContextDataFinalOutput = new runtime_industries_cpq.AdditionalContextData();
15    }
16    
17    // This method is invoked from a Flow
18    @InvocableMethod(label='Process Input' description='Creates the Array of ContextDataInput for additional Context Data')
19    public static List<FlowOutput> processContextData(List<FlowInput> inputs){
20        String apiName;
21        String recId;
22        FlowOutput output = new FlowOutput();
23        
24    // Capture input from the flow
25        for(FlowInput input: inputs){
26            apiName = input.objectApiName;
27            recId = input.recordId;
28            }
29    // Populate the ContextDataInput list to store additional context data    
30        List<runtime_industries_cpq.ContextDataInput> listContextData = new List<runtime_industries_cpq.ContextDataInput>();
31        runtime_industries_cpq.ContextDataInput cd1 = new runtime_industries_cpq.ContextDataInput();
32        cd1.nodeName = apiName;
33        cd1.nodeData = new Map<String, Object>();
34        cd1.nodeData.put('id',recId);
35        listContextData.add(cd1);
36       
37        output.additionalContextDataFinalOutput.additionalContextData = listContextData;
38        List<FlowOutput> flowOutputs = new List<FlowOutput>();
39        flowOutputs.add(output);
40        
41        List<runtime_industries_cpq.RelatedObjectFilter> relatedObjectFilterList = new List<runtime_industries_cpq.RelatedObjectFilter>();
42       
43        runtime_industries_cpq.RelatedObjectFilter relatedObjectFilter = new runtime_industries_cpq.RelatedObjectFilter();
44
45        relatedObjectFilter.objectName = 'ProductSpecificationRecType';
46        List<runtime_industries_cpq.FilterCriteriaInputRepresentation> criteriaList = new  List<runtime_industries_cpq.FilterCriteriaInputRepresentation>();
47        runtime_industries_cpq.FilterCriteriaInputRepresentation criteria = new runtime_industries_cpq.FilterCriteriaInputRepresentation();
48        criteria.property = 'IsCommercial';
49        criteria.operator = 'eq';
50        criteria.value = 'true';
51        criteriaList.add(criteria);
52        relatedObjectFilter.criteria = criteriaList;
53
54        relatedObjectFilterList.add(relatedObjectFilter);
55        output.relatedObjectFilter.relatedObjectFilter  = relatedObjectFilterList;
56         
57		output.userContext.accountId = '001DU000001nx9BYAQ';
58        
59        return flowOutputs;
60       
61    }
62
63}

Create a Flow with the Necessary Variables and Components: Create a flow that enables users to add a search term to find products. Add the ProductService action that you’ve created above by using Apex. When a flow is invoked from a record, the flow sends the record’s objectApiName and recordId to the Apex class, which then generates the flow output. The flow passes the objectApiName and recordId of the record that the flow is invoked from to the Apex class to generate the flow output. See Example of How to Create a Flow for Product Discovery.

Configure the Action: Configure the action (for example, Find Products action) to add values for the Apex-defined input parameters. Use the output of the created Apex class as the input of the Apex-defined parameter in the Find Products action, which users can use to find products.