Add Eligible Insurance Clauses Action

Add eligible insurance clauses to a quote or context. You must specify either a quote ID or a context ID, and either an instance key or a quote line item ID along with insurance product clause details.

This action is available in API version 65.0 and later.

Supported REST HTTP Methods

URI: /services/data/vXX.X/actions/standard/addEligibleInsuranceClauses

Where XX.X is the latest API version.

Formats: JSON, XML

HTTP Methods: POST

Authentication: Authorization: Bearer TOKEN

Where TOKEN is your OAuth access token.

Inputs

Input Type Description
contextId string Required if quoteId isn't specified. Context ID of the insurance quote.
instanceKey string Required if quoteLineItemId isn't specified. Unique key that identifies the product to which a quote line item belongs.
insuranceProductClauses string Required. JSON object with the details of the insurance product clauses to add.
optionFlags Apex-defined An Apex runtime_industries_insurance.AddEligibleInsuranceClausesOptions record that contains the details to add eligible clauses to an insurance product.
quoteId string Required if contextId isn't specified. ID of the insurance quote to add eligible clauses.
quoteLineItemId string Required if instanceKey isn't specified. ID of the quote line items for adding eligible clauses.

Outputs

Output Type Description
errorsList string Errors that are encountered during the operation.
isSuccess boolean Indicates whether the operation is successful ( true ) or not ( false ).
quoteLineItemInsProductClauseIds string IDs of the quote line item insurance product clauses.

Example

Sample Request

{
  "inputs": [
    {
      "quoteId": "0Q0xx0000000001AAA",
      "quoteLineItemId": "0QLxx0000000002BBB",
      "contextId": "0j5xx0000000003CCC",
      "instanceKey": [
        "Auto",
        "Liability"
      ],
      "insuranceProductClauses": [
        {
          "insuranceProductClauseId": "0j4xx0000000004DDD",
          "effectiveDate": "2025-01-01",
          "expirationDate": "2025-12-31"
        }
      ],
      "optionFlags": {
        "saveContext": true
      }
    }
  ]
}

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

public class AddEligibleInsuranceClausesInvoke {
    private static final String ACTION_NAME = 'addEligibleInsuranceClauses';

    public static Boolean invokeMethod(Map<String, Object> inputs, Map<String, Object> output) {
        if (output == null) {
            output = new Map<String, Object>();
        }

        try {
            Invocable.Action action = Invocable.Action.createStandardAction(ACTION_NAME);

            // Either quoteId or contextId is required
            setInvocationParameter(action, inputs, 'quoteId', false);
            setInvocationParameter(action, inputs, 'contextId', false);

            // Either quoteLineItemId or instanceKey is required
            setInvocationParameter(action, inputs, 'quoteLineItemId', false);
            setInvocationParameter(action, inputs, 'instanceKey', false);

            // insuranceProductClauses expects JSON
            setInvocationParameter(action, inputs, 'insuranceProductClauses', true);

            // Optional optionFlags map
            if (inputs != null && inputs.containsKey('optionFlags')) {
                Map<String, Object> addClauseOptions =
                    (Map<String, Object>) inputs.get('optionFlags');
                if (addClauseOptions != null) {
                    runtime_industries_insurance.AddEligibleInsuranceClausesOptions apexOptions =
                        new runtime_industries_insurance.AddEligibleInsuranceClausesOptions();
                    if (addClauseOptions.containsKey('saveContext')) {
                        apexOptions.SaveContext =
                            (Boolean) addClauseOptions.get('saveContext');
                    }
                    action.setInvocationParameter('addClauseOptions', apexOptions);
                }
            }

            List<Invocable.Action.Result> results = action.invoke();
            if (results != null && !results.isEmpty() && results[0].isSuccess()) {
                output.put('output', results[0].getOutputParameters());
                output.put('success', true);
                return true;
            }

            output.put('success', false);
            if (results != null && !results.isEmpty()) {
                output.put('errors', results[0].getErrors());
            }
            return false;
        } catch (Exception e) {
            output.put('success', false);
            output.put('errorMessage', e.getMessage());
            return false;
        }
    }

    private static void setInvocationParameter(
        Invocable.Action action,
        Map<String, Object> payload,
        String attribute,
        Boolean serializeJson
    ) {
        if (payload != null && payload.containsKey(attribute) && payload.get(attribute) != null) {
            if (serializeJson) {
                action.setInvocationParameter(attribute, JSON.serialize(payload.get(attribute)));
            } else {
                action.setInvocationParameter(attribute, payload.get(attribute));
            }
        }
    }
}

Sample Response

[
  {
    "actionName": "addEligibleInsuranceClauses",
    "errors": null,
    "invocationId": null,
    "isSuccess": true,
    "outcome": null,
    "outputValues": {
      "isSuccess": true,
      "quoteLineItemInsProductClauseIds": [
        "a1Cxx0000000001AAA"
      ],
      "errorsList": []
    },
    "sortOrder": -1,
    "version": 1
  }
]