Newer Version Available

This content describes an older version of this product. View Latest

Reprice Insurance Product Action

Recalculate the price of insurance products based on user inputs.

This action is available in API version 63.0 and later.

Supported REST HTTP Methods

URI
/services/data/v66.0/actions/standard/repriceInsuranceProduct
Formats
JSON
HTTP Methods
GET, POST
Authentication
Bearer Token

Inputs

Input Details
addedNodes
Type
String
Description
Product instances details that are added.
additionalFields
Type
String
Description
Map of additional fields that must be updated in the insurance quote context.
contextId
Type
String
Description
Required.
Context ID of the Insurance quote.
deletedNodes
Type
String
Description
Set of deleted product instances details.
effectiveDate
Type
Date
Description
Date that the quote becomes effective.
executeRating
Type
String
Description
Indicates whether rating must be executed (true) or not (false). The default value is true.
executeConfigurationRules
Type
Boolean
Description
Indicates whether configuration rules must be executed (true) or not (false). The default value is false.
pricingProcedureApiName
Type
String
Description
API name of the pricing procedure that's used to price the product.
This property is deprecated from version 66.0 and later.
ratingDate
Type
Date
Description
Date that's used to find the active pricing procedure.
returnContextJson
Type
Date
Description
Indicates whether context JSON must be returned (true) or not (false).
The default value is false.
returnProductDetails
Type
Date
Description
Indicates whether product details must be returned (true) or not (false).
The default value is false.
returnRatingResults
Type
Date
Description
Indicates whether rating results must be returned as an Apex class (true) or not (false).
The default value is false.
updatedNodes
Type
String
Description
Set of product instances details that are updated.

Outputs

Output Details
contextId Type

String

Description

Context ID of the insurance quote.

pricingResults Type

Map<String, Object>

Description

Pricing details of the insurance product that are recalculated.

productRatingOutput Type

Apex-defined

Description

An Apex ConnectApi__ProductRatingOutputRepresentation record that contains the product rating details.

Example

Sample Request

1{
2  "inputs": [
3    {
4      "contextId": "273e01fdfb6f9f21428869eb784ee756976afb0e9bdc49f2a360be397a10ca12",
5      "effectiveDate": "2024-10-18",
6      "addedNodes": "[{\"instanceKeys\":[\"AutoRoot\",\"AutoBundle\",\"NewDriver\"],\"productCode\":\"autoDriver\",\"attributes\":{\"DriverAccidents\":4},\"targetRecords\":[\"003xx000004WhKhAAK\"]}]",
7      "returnRatingResults": true,
8      "returnContextJson": true,
9      "returnProductDetails": true
10    }
11  ]
12}

This is a sample request to call this invocable action from Apex code.

1// Sample Apex call for repriceInsuranceProduct invocable action
2public class RepriceInsuranceProductInvoke {
3    private static final String ACTION_NAME = 'repriceInsuranceProduct';
4
5    public static Boolean invokeMethod(
6        Map<String, Object> inputs,
7        Map<String, Object> output,
8        Map<String, Object> options
9    ) {
10        Map<String, Object> patchPayload = (Map<String, Object>) getValueFromMap('patchPayload', inputs, options);
11        System.debug('Rating patch Input: ' + patchPayload);
12
13        if (patchPayload == null) {
14            output.put('success', false);
15            output.put('errorMessage', 'patchPayload is required for rating patch');
16            output.put('errorType', 'VALIDATION_ERROR');
17            return false;
18        }
19
20        try {
21            System.debug('Calling Invocable Action: repriceInsuranceProduct');
22
23            Invocable.Action action = Invocable.Action.createStandardAction(ACTION_NAME);
24
25            System.debug('Context Id::::::::' + patchPayload.get('contextId'));
26            action.setInvocationParameter('contextId', patchPayload.get('contextId'));
27
28            System.debug('Updated Nodes::::::::' + patchPayload.get('updatedNodes'));
29            setInvocationParameter(action, patchPayload, 'updatedNodes', true);
30
31            System.debug('Added Nodes::::::::' + patchPayload.get('addedNodes'));
32            setInvocationParameter(action, patchPayload, 'addedNodes', true);
33
34            System.debug('Deleted Nodes::::::::' + patchPayload.get('deletedNodes'));
35            setInvocationParameter(action, patchPayload, 'deletedNodes', true);
36
37            if (patchPayload.containsKey('executeRating')) {
38                System.debug('Options::::::::' + patchPayload.get('executeRating'));
39                action.setInvocationParameter('executeRating', patchPayload.get('executeRating'));
40            }
41
42            if (patchPayload.containsKey('executeConfigurationRules')) {
43                System.debug('Options::::::::' + patchPayload.get('executeConfigurationRules'));
44                action.setInvocationParameter('executeConfigurationRules', patchPayload.get('executeConfigurationRules'));
45            }
46
47            if (patchPayload.containsKey('returnContextJSON')) {
48                System.debug('Options::::::::' + patchPayload.get('returnContextJSON'));
49                action.setInvocationParameter('returnContextJSON', patchPayload.get('returnContextJSON'));
50            }
51
52            if (patchPayload.containsKey('returnProductDetails')) {
53                System.debug('Options::::::::' + patchPayload.get('returnProductDetails'));
54                action.setInvocationParameter('returnProductDetails', patchPayload.get('returnProductDetails'));
55            }
56
57            if (patchPayload.containsKey('returnRatingResults')) {
58                System.debug('Options::::::::' + patchPayload.get('returnRatingResults'));
59                action.setInvocationParameter('returnRatingResults', patchPayload.get('returnRatingResults'));
60            }
61
62            List<Invocable.Action.Result> results = action.invoke();
63
64            if (results != null && !results.isEmpty()) {
65                Invocable.Action.Result result = results[0];
66
67                if (result.isSuccess()) {
68                    System.debug('Rating patch successfully via Invocable Action');
69                    output.put('ratingData', result.getOutputParameters());
70
71                    Map<String, Object> outputParams = result.getOutputParameters();
72                    if (outputParams != null) {
73                        if (outputParams.containsKey('contextId')) {
74                            output.put('contextId', outputParams.get('contextId'));
75                        }
76                        if (outputParams.containsKey('contextJSON')) {
77                            output.put('contextJSON', outputParams.get('contextJSON'));
78                        }
79                        if (outputParams.containsKey('pricingResult')) {
80                            output.put('pricingResult', outputParams.get('pricingResult'));
81                        }
82                        if (outputParams.containsKey('productDetails')) {
83                            output.put('productDetails', outputParams.get('productDetails'));
84                        }
85
86                        System.debug('Rating Patch data extracted: ' + outputParams);
87                    }
88                    List<Invocable.Action.Error> actionErrors = result.getErrors();
89                    if (actionErrors != null && !actionErrors.isEmpty()) {
90                        output.put('success', false);
91                        output.put('error', result.getErrors());
92                        return false;
93                    }
94                    output.put('success', true);
95                    return true;
96
97                } else {
98                    List<Invocable.Action.Error> actionErrors = result.getErrors();
99                    String errorMessage = 'Rating Patch Invocable Action failed';
100
101                    if (actionErrors != null && !actionErrors.isEmpty()) {
102                        List<String> errorMessages = new List<String>();
103                        List<Map<String, Object>> errorDetailsList = new List<Map<String, Object>>();
104
105                        for (Invocable.Action.Error actionError : actionErrors) {
106                            errorMessages.add(actionError.getMessage());
107                            errorDetailsList.add(new Map<String, Object>{
108                                'message' => actionError.getMessage(),
109                                'code' => actionError.getCode()
110                            });
111                        }
112
113                        errorMessage = String.join(errorMessages, '; ');
114                        output.put('actionErrors', errorDetailsList);
115                    }
116
117                    output.put('success', false);
118                    output.put('errorMessage', errorMessage);
119
120                    System.debug(LoggingLevel.ERROR, 'Rating Patch Invocable Action failed: ' + errorMessage);
121                    return false;
122                }
123
124            } else {
125                output.put('success', false);
126                output.put('errorMessage', 'Rating Patch Invocable Action returned null or empty results');
127                System.debug(LoggingLevel.WARN, 'Rating Patch Invocable Action returned null/empty results');
128                return false;
129            }
130
131        } catch (Exception e) {
132            String errorMsg = 'Exception: ' + e.getMessage();
133            output.put('success', false);
134            output.put('errorMessage', errorMsg);
135            output.put('errorType', 'EXCEPTION');
136            System.debug(LoggingLevel.ERROR, 'Exception while rating patch: ' + errorMsg);
137            return false;
138        }
139    }
140
141    private static Object getValueFromMap(String key, Map<String, Object> inputs, Map<String, Object> options) {
142        if (inputs != null && inputs.get(key) != null && String.isNotBlank(String.valueOf(inputs.get(key)))) {
143            return inputs.get(key);
144        }
145        else if (options != null && options.get(key) != null && String.isNotBlank(String.valueOf(options.get(key)))) {
146            return options.get(key);
147        }
148
149        return null;
150    }
151
152    private static void setInvocationParameter(
153        Invocable.Action action,
154        Map<String, Object> payload,
155        String inputAttribute,
156        Boolean serializeJSON
157    ) {
158        if (payload.containsKey(inputAttribute) && payload.get(inputAttribute) != null) {
159            System.debug(inputAttribute + ': ' + JSON.serialize(payload.get(inputAttribute)));
160            if (serializeJSON) {
161                action.setInvocationParameter(inputAttribute, JSON.serialize(payload.get(inputAttribute)));
162            } else {
163                action.setInvocationParameter(inputAttribute, payload.get(inputAttribute));
164            }
165        } else {
166            System.debug('payload does not contain attribute: ' + inputAttribute);
167        }
168    }
169}

Sample Response

1[
2  {
3    "actionName": "repriceInsuranceProduct",
4    "errors": null,
5    "invocationId": null,
6    "isSuccess": true,
7    "outcome": null,
8    "outputValues": {
9      "contextId": "273e01fdfb6f9f21428869eb784ee756976afb0e9bdc49f2a360be397a10ca12",
10      "productRatingOutput": {
11        "ratingResult": {
12          "childNodes": [
13            {
14              "childNodes": [
15                {
16                  "childNodes": [
17                    {
18                      "childNodes": [],
19                      "details": {
20                        "NetUnitPrice": null,
21                        "InstanceKey": "Driver",
22                        "ProductCode": "driver",
23                        "NetTotalPrice": 0,
24                        "Driver_Accident_Points": 15,
25                        "ProratedQLITaxAmount": 0,
26                        "Driver_MVR_Points": 8,
27                        "Age_First_Licensed": 16
28                      }
29                    },
30                    {
31                      "childNodes": [],
32                      "details": {
33                        "NetUnitPrice": 501.84,
34                        "InstanceKey": "Comprehensive",
35                        "ProductCode": "comprehensive",
36                        "NetTotalPrice": 501.84,
37                        "ProratedQLITaxAmount": 0
38                      }
39                    }
40                  ],
41                  "details": {
42                    "NetUnitPrice": 501.84,
43                    "InstanceKey": "Auto1",
44                    "ProductCode": "auto",
45                    "NetTotalPrice": 501.84,
46                    "ProratedQLITaxAmount": 0
47                  }
48                }
49              ],
50              "details": {
51                "NetUnitPrice": 1485.84,
52                "InstanceKey": "AutoSilver",
53                "ProductCode": "autoSilver",
54                "NetTotalPrice": 1485.84,
55                "ProratedQLITaxAmount": 0
56              }
57            }
58          ],
59          "details": {}
60        },
61        "productDetails": [
62          {
63            "productSpecificationType": {
64              "productSpecificationRecordType": {},
65              "name": "InsuredParty"
66            },
67            "childProducts": [],
68            "additionalFields": {
69              "ProductCode": "driver",
70              "SpecificationType": "InsuredParty",
71              "BasedOnId": "11Bxx000002C1kZEAS",
72              "Name": "Driver"
73            },
74            "availabilityDate": null,
75            "description": null,
76            "productInformation": null,
77            "childVariationIds": [],
78            "isActive": true,
79            "qualificationContext": null,
80            "productClassification": {
81              "id": "11Bxx000002C1kZEAS"
82            },
83            "productComponentGroups": [],
84            "configureDuringSale": "Allowed",
85            "productRelatedComponent": null,
86            "id": "01txx0000006i3iAAA",
87            "prices": [],
88            "isComponentRequired": null,
89            "productType": null,
90            "isAssetizable": true,
91            "isSoldOnlyWithOtherProds": false,
92            "attributeCategories": [
93              {
94                "code": "Driving History",
95                "records": [
96                  {
97                    "isRequired": false,
98                    "code": "AgeFirstLicensed",
99                    "additionalFields": {},
100                    "attributeCategoryId": "0v3xx0000000001AAA",
101                    "hidden": false,
102                    "isConfigurable": false,
103                    "dataType": "NUMBER",
104                    "label": "Age First Licensed",
105                    "isReadOnly": false,
106                    "isCloneable": false,
107                    "name": "Age First Licensed",
108                    "id": "0tjxx000000001FAAQ",
109                    "attributeNameOverride": "Age First Licensed",
110                    "isPriceImpacting": true,
111                    "developerName": "Age_First_Licensed",
112                    "status": "Active"
113                  }
114                ],
115                "name": "Driving History"
116              }
117            ],
118            "nodeType": "simpleProduct",
119            "displayUrl": null,
120            "productSellingModelOptions": [
121              {
122                "productSellingModel": {
123                  "sellingModelType": "OneTime",
124                  "name": "One Time",
125                  "id": "0jPxx0000000001EAA",
126                  "doesAutoRenewByDefault": false,
127                  "status": "Active"
128                },
129                "productSellingModelId": "0jPxx0000000001EAA",
130                "isDefault": true,
131                "productId": "01txx0000006i3iAAA",
132                "id": "0iOxx000000000zEAA"
133              }
134            ],
135            "productQuantity": null,
136            "productCode": "driver",
137            "name": "Driver"
138          }
139        ],
140        "contextJSON": {
141          "salesTransactions": [
142            {
143              "salesTransactionItems": [
144                {
145                  "salesTransactionItemClauses": [],
146                  "childNodes": [
147                    {
148                      "salesTransactionItemClauses": [],
149                      "childNodes": [],
150                      "salesTransactionItemAttributes": [
151                        {
152                          "fields": {
153                            "AttributeKey": "0tjxx000000000PAAQ",
154                            "AttributeValue": "50",
155                            "ParentReference": "ref_681c203e_5491_4d5f_a296_02a0b3dfa181",
156                            "hasObjectRef": null,
157                            "AttributePicklistValue": "0v6xx000000000ZAAQ",
158                            "IsPriceImpacting": false,
159                            "businessObjectType": "QuoteLineItemAttribute",
160                            "AttributeName": "Deductible",
161                            "AttributeDefinitionCode": "Deductible",
162                            "id": "ref_fdd78e30_1258_4ea3_9f56_c74245ae58d6",
163                            "SalesTransactionItemAttrParent": "ref_681c203e_5491_4d5f_a296_02a0b3dfa181",
164                            "AttributeDeveloperName": "Deductible"
165                          }
166                        }
167                      ]
168                    }
169                  ],
170                  "salesTransactionItemRelatedObjects": [],
171                  "salesTransactionItemTaxes": [],
172                  "fields": {
173                    "LevelTwoBasePremium": 120,
174                    "IntermediateVariableTwo": null,
175                    "Product": "01txx0000006i3UAAQ",
176                    "businessObjectType": "QuoteLineItem",
177                    "DYN__License_State": null,
178                    "RevenueCloudPackagingFlag": "C",
179                    "ValidationResult": null,
180                    "DYN__AssetRecordName": null,
181                    "PolicyPremium": 1485.84,
182                    "PeriodBoundaryStartMonth": null,
183                    "SalesTransactionSourceAsset": null,
184                    "ProratedQLITaxAmount": 0,
185                    "id": "ref_681c203e_5491_4d5f_a296_02a0b3dfa181",
186                    "TaxTreatment": null,
187                    "Subtotal": null,
188                    "LineItemPath": "ref_e112c127_367c_41c8_a5ce_1d7e69ac58bc/ref_681c203e_5491_4d5f_a296_02a0b3dfa181",
189                    "DiscountAmount": null,
190                    "PricebookEntry": null,
191                    "NetUnitPrice": 590.4,
192                    "ParentSalesTransactionItem": "ref_e112c127_367c_41c8_a5ce_1d7e69ac58bc",
193                    "ObligatedAmount": null,
194                    "DYN__Age_First_Licensed": null,
195                    "LevelThreePremium": null,
196                    "ProductName": "Bodily Injury &amp; Property Damage",
197                    "ProformaBillingPeriodAmount": null,
198                    "CommissionAmount": null,
199                    "ProductSpec": "Coverage",
200                    "DYN__Last_Name": null,
201                    "PricingTermCount": null,
202                    "DYN__ContactRecordName": null,
203                    "RoundedLineAmount": null,
204                    "SalesTransactionAction": null,
205                    "TransactionType": null,
206                    "PricingTermUnit": null,
207                    "BasisTransactionItem": null,
208                    "PricingSource": null,
209                    "StockKeepingUnit": null,
210                    "DYN__Year": null,
211                    "PartnerUnitPrice": null,
212                    "ItemTotalAdjustmentAmount": null,
213                    "ArePartialPeriodsAllowed": false,
214                    "DYN__Bodily_Injury_Per_Person_Limit": 1000,
215                    "DYN__Colour": null,
216                    "FactorP": null,
217                    "FactorO": null,
218                    "CustomProductName": null,
219                    "SalesTransactionItemParent": "ref_ed3d9643_12e4_4709_9f74_69c8292d65b4",
220                    "Quantity": 1,
221                    "ContractId": null,
222                    "ItemGroupSummarySubtotal": null,
223                    "DYN__AccountRecordName": null,
224                    "DYN__E_Mail": null,
225                    "DYN__First_Name": null,
226                    "DYN__Bodily_Injury_Per_Accident_Limit": 1000,
227                    "DYN__Driver_Accident_Points": null,
228                    "SalesItemType": null,
229                    "ItemPath": "01txx0000006i3DAAQ/01txx0000006i3UAAQ"
230                  },
231                  "salesTransactionItemRelationships": [
232                    {
233                      "fields": {
234                        "ParentReference": "ref_681c203e_5491_4d5f_a296_02a0b3dfa181",
235                        "AssociatedItem": "ref_681c203e_5491_4d5f_a296_02a0b3dfa181",
236                        "MainItemRole": null,
237                        "ProductRelatedComponent": "0dSxx000000000XEAQ",
238                        "businessObjectType": "QuoteLineRelationship",
239                        "AssociatedItemPricing": "IncludedInBundlePrice",
240                        "ProductRelationshipType": "0yoxx0000000001AAA",
241                        "RootItemProductCode": "autoSilver",
242                        "IsPriceInclusive": true,
243                        "RootItem": "ref_e112c127_367c_41c8_a5ce_1d7e69ac58bc",
244                        "RootItemProductSellingModel": null,
245                        "AssociatedQuantScaleMethod": null,
246                        "MainItem": "ref_e112c127_367c_41c8_a5ce_1d7e69ac58bc",
247                        "AssociatedItemRole": null,
248                        "SalesTrnItemRelationshipParent": null,
249                        "id": "ref_80623cb4_3abd_4ee0_876a_c5ca9ecc07fc",
250                        "MainItemProduct": "01txx0000006i3DAAQ",
251                        "MainItemProductSellingModel": null,
252                        "RootItemProduct": "01txx0000006i3DAAQ"
253                      }
254                    }
255                  ]
256                }
257              ],
258              "salesTransactionItemAttributes": [],
259              "salesTransactionItemRelatedObjects": [],
260              "salesTransactionItemTaxes": [],
261              "fields": {
262                "LevelTwoBasePremium": null,
263                "IntermediateVariableTwo": null,
264                "Product": "01txx0000006i3DAAQ",
265                "businessObjectType": "QuoteLineItem",
266                "DYN__License_State": null,
267                "RevenueCloudPackagingFlag": "C",
268                "ValidationResult": null,
269                "DYN__AssetRecordName": null,
270                "PolicyPremium": 1485.84,
271                "PeriodBoundaryStartMonth": null,
272                "SalesTransactionSourceAsset": null,
273                "ProratedQLITaxAmount": 0,
274                "id": "ref_e112c127_367c_41c8_a5ce_1d7e69ac58bc",
275                "DYN__Age": null,
276                "DYN__Property_Damage_Per_Accident_Limit": null,
277                "DYN__Deductible": null,
278                "STICurrencyIsoCode__std": null,
279                "IntermediateVariableOne": null,
280                "BillingFrequency": null,
281                "DYN__State": null,
282                "DYN__DOB": null,
283                "ProductCode": "autoSilver",
284                "DerivedPricingAttribute": false,
285                "ItemPath": "01txx0000006i3DAAQ"
286              },
287              "salesTransactionItemRelationships": []
288            }
289          ],
290          "fields": {
291            "Account": null,
292            "BillingCity": null,
293            "businessObjectType": "Quote",
294            "SalesTransactionName": null,
295            "StatusCode": null,
296            "ProratedAmount": 1485.84,
297            "StartDate": "2025-11-04",
298            "CurrencyIsoCode__std": null,
299            "BillingPostalCode": null,
300            "id": "ref_ed3d9643_12e4_4709_9f74_69c8292d65b4",
301            "BillingState": null,
302            "CensusRatingType__std": null,
303            "TransactionType": "AutoTransactionType",
304            "UserProfile": "System Administrator",
305            "QuoteAccount": null,
306            "TotalProratedAmount": 1485.84,
307            "CensusType__std": null,
308            "GroupCensus": null,
309            "SalesTransactionType": null,
310            "Pricebook": null,
311            "Opportunity": null,
312            "ShippingCountry": null,
313            "ShippingCity": null,
314            "StandardAmount": 1485.84,
315            "ProratedTaxAmount": 0,
316            "RatingDate": null,
317            "SalesTransactionSource": "ref_ed3d9643_12e4_4709_9f74_69c8292d65b4",
318            "EffectiveDate": "2025-11-04T00:00:00.000Z",
319            "TotalStandardAmount": 1485.84
320          },
321          "appUsageAssignments": []
322        }
323      }
324    },
325    "sortOrder": -1,
326    "version": 1
327  }
328]