Create Insurance Quote Action

Create an Insurance quote by using a context ID or a set of user inputs that represent quote details.

This action is available in API version 63.0 and later.

Supported REST HTTP Methods

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

Inputs

If you specify quoteInputs (but not contextId) in the request body, you must provide quoteName, priceBookId, and effectiveDate as input parameters.

If you specify contextId (but not quoteInputs) in the request body, you must provide these:

  • either quoteName or SalesTransactionName within additionalFields, and
  • either priceBookId or PriceBook within additionalFields
Input Details
accountId
Type
String
Description
ID of the account that's associated with the quote being created.
additionalFields
Type
String
Description
Optional. Map of additional fields that must be updated in the quote context.
contextId
Type
String
Description
Required if quoteInputs isn't specified.
Context ID that's used to issue the quote.
effectiveDate
Type
Date
Description
Date that the quote becomes effective.
expirationDate
Type
Date
Description
Optional. Expiration date of the quote.
opportunityId
Type
String
Description
Optional. ID of the opportunity that's associated with the quote.
pricebookId
Type
String
Description
Required if either quoteInputs or contextId is specified.
ID of the pricebook that's associated with the quote.
pricingProcedureApiName
Type
String
Description
Optional. API name of the pricing procedure used to price the product.
quoteInputs
Type
String
Description
Required if contextId isn't specified.
Set of user inputs on products that represent the quote details.
quoteOptions
Type
Apex-defined
Description
An Apex runtime_industries_insurance.CreateInsuranceQuoteOptions record that contains details to create the quote.
quoteName
Type
String
Description
Name of the quote that must be created.
ratingDate
Type
Date
Description
Optional. Date to find the active pricing procedure.

Outputs

Output Details
contextId Type

String

Description

Context ID of the insurance quote that's created.

quoteId Type

String

Description

ID of the insurance quote that's created.

Example

Sample request where quoteInputs is specified in the request body.

1{
2  "inputs":[
3    {
4      "quoteName": "Auto Insurance Quote",
5      "priceBookId" : "01sxx0000005pyfAAA",
6      "accountId": "001xx000003GYwrAAG",
7      "effectiveDate": "2024-10-11",
8      "opportunityId": "006xx000001a2tbAAA",
9      "quoteOptions": {
10         "productSellingModel": "One Time",
11         "saveQuote": true
12      },
13      "quoteInputs": "[{\"productCode\":\"autoRoot\",\"instanceKeys\":[\"AutoRoot\"],\"items\":[{\"productCode\":\"autoBundle\",\"instanceKeys\":[\"AutoRoot\",\"AutoBundle\"],\"attributes\":{\"avMake\":\"BMW\"},\"relatedRecords\":[{\"relatedRecordId\":\"001xx000003GYwrAAG\",\"relatedRecordObjName\":\"Account\"}]},{\"productCode\":\"autoDriver\",\"instanceKeys\":[\"AutoRoot\",\"AutoBundle\",\"AutoDriver\"],\"relatedRecords\":[{\"relatedRecordId\":\"003xx000004WhKhAAK\",\"relatedRecordObjName\":\"Contact\"}]},{\"productCode\":\"autoRental\",\"instanceKeys\":[\"AutoRoot\",\"AutoBundle\",\"AutoRental\"]},{\"productCode\":\"autoCollision\",\"instanceKeys\":[\"AutoRoot\",\"AutoBundle\",\"autoCollision\"],\"attributes\":{\"CollisionBasePremium\":250,\"autoCollDedClmCov\":250}}]}]"
14    }
15  ]
16}

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

1// Sample Apex call for createInsuranceQuote invocable action
2public class CreateInsuranceQuoteInvoke {
3    private static final String ACTION_NAME = 'createInsuranceQuote';
4
5    public static Boolean invokeMethod(Map<String, Object> inputs, Map<String, Object> output) {
6        if (output == null) {
7            output = new Map<String, Object>();
8        }
9
10        try {
11            Invocable.Action action = Invocable.Action.createStandardAction(ACTION_NAME);
12
13            // Required inputs (serialize where needed)
14            setInvocationParameter(action, inputs, 'quoteInputs', true);
15            setInvocationParameter(action, inputs, 'quoteName', false);
16            setInvocationParameter(action, inputs, 'priceBookId', false);
17            setInvocationParameter(action, inputs, 'accountId', false);
18            setInvocationParameter(action, inputs, 'effectiveDate', false);
19
20            // Optional inputs
21            setInvocationParameter(action, inputs, 'contextId', false);
22            setInvocationParameter(action, inputs, 'expirationDate', false);
23            setInvocationParameter(action, inputs, 'additionalFields', true);
24            setInvocationParameter(action, inputs, 'opportunityId', false);
25
26            // quoteOptions is optional but supported
27            if (inputs != null && inputs.containsKey('quoteOptions')) {
28                Map<String, Object> optionsFromInput =
29                    (Map<String, Object>) inputs.get('quoteOptions');
30                if (optionsFromInput != null) {
31                    runtime_industries_insurance.CreateInsuranceQuoteOptions quoteOptions =
32                        new runtime_industries_insurance.CreateInsuranceQuoteOptions();
33                    if (optionsFromInput.containsKey('executePricing')) {
34                        quoteOptions.executePricing =
35                            (Boolean) optionsFromInput.get('executePricing');
36                    }
37                    if (optionsFromInput.containsKey('validateProductCatalog')) {
38                        quoteOptions.validateProductCatalog =
39                            (Boolean) optionsFromInput.get('validateProductCatalog');
40                    }
41                    if (optionsFromInput.containsKey('executeConfigurationRules')) {
42                        quoteOptions.executeConfigurationRules =
43                            (Boolean) optionsFromInput.get('executeConfigurationRules');
44                    }
45                    if (optionsFromInput.containsKey('executeQualificationRules')) {
46                        quoteOptions.executeQualificationRules =
47                            (Boolean) optionsFromInput.get('executeQualificationRules');
48                    }
49                    if (optionsFromInput.containsKey('saveQuote')) {
50                        quoteOptions.saveQuote =
51                            (Boolean) optionsFromInput.get('saveQuote');
52                    }
53                    if (optionsFromInput.containsKey('productSellingModel')) {
54                        quoteOptions.productSellingModel =
55                            (String) optionsFromInput.get('productSellingModel');
56                    }
57                    action.setInvocationParameter('quoteOptions', quoteOptions);
58                }
59            }
60
61            List<Invocable.Action.Result> results = action.invoke();
62            if (results != null && !results.isEmpty() && results[0].isSuccess()) {
63                output.put('output', results[0].getOutputParameters());
64                output.put('success', true);
65                return true;
66            }
67
68            output.put('success', false);
69            if (results != null && !results.isEmpty()) {
70                output.put('errors', results[0].getErrors());
71            }
72            return false;
73        } catch (Exception e) {
74            output.put('success', false);
75            output.put('errorMessage', e.getMessage());
76            return false;
77        }
78    }
79
80    private static void setInvocationParameter(
81        Invocable.Action action,
82        Map<String, Object> payload,
83        String attribute,
84        Boolean serializeJson
85    ) {
86        if (payload != null && payload.containsKey(attribute) && payload.get(attribute) != null) {
87            if (serializeJson) {
88                action.setInvocationParameter(attribute, JSON.serialize(payload.get(attribute)));
89            } else {
90                action.setInvocationParameter(attribute, payload.get(attribute));
91            }
92        }
93    }
94}

Sample Response

1[
2  {
3    "actionName": "createInsuranceQuote",
4    "errors": null,
5    "invocationId": null,
6    "isSuccess": true,
7    "outcome": null,
8    "outputValues": {
9      "contextId": "0000000i18tq18g00291753491065771466a599fe8a2440890b4f3d8b4ef40b5",
10      "quoteId": "0Q0SG000000OOUD0A4"
11    },
12    "sortOrder": -1,
13    "version": 1
14  }
15]