|
| 1 | +# Product Configuration Lightning Web Component |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The `productConfiguration` Lightning Web Component (LWC) is designed for Digital Insurance Product Configuration workflows. It extends `OmniscriptBaseMixin` to integrate seamlessly with OmniScripts, and makes it easy for users to view, configure, and rate insurance products. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Dependencies |
| 10 | + |
| 11 | +- **Apex Controller**: `InsuranceRatingApexService.postRatingFromLwc` |
| 12 | +- **Apex Controller**: `InsuranceRatingApexService.patchRatingFromLwc` |
| 13 | +- **Mixin**: `c/omniscriptBaseMixin` (follow the steps under [Prerequisites](../../../README.md#prerequisites)) |
| 14 | +- **Helper Modules**: |
| 15 | + - `dataManager.js` – Tree building and grid transformation utilities |
| 16 | + - `labelsAndConstants.js` – Validation messages, labels, and constants |
| 17 | + |
| 18 | +## Components Included |
| 19 | + |
| 20 | +| Component | Description | |
| 21 | +| :---- | :---- | |
| 22 | +| `productConfiguration` | Main component for displaying, configuring and rating insurance products.| |
| 23 | +| `productConfigurationMessageItem` | Notification component used to display validation results, configuration errors, or informational messages within the product.| |
| 24 | + |
| 25 | +### Supporting Files |
| 26 | + |
| 27 | +| File | Type | Description | |
| 28 | +| :---- | :---- | :---- | |
| 29 | +| `InsuranceRatingApexService.cls` | Apex Class | Service class that wraps the createInsuranceRating and repriceInsuranceProduct invocable action.| |
| 30 | +| `ProductSelectionLabels.labels` | Custom Labels | UI text labels for translation support | |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## Public Properties (`@api`) |
| 35 | + |
| 36 | +| Property | Type | Default | Description | |
| 37 | +| :---- | :---- | :---- | :---- | |
| 38 | +| `additionalFields` | `Object` | `{}` | Additional fields to include in the rating request payload. | |
| 39 | +| `clearStateOnChange` | `String` | — | JSON stringified array of element names whose state should be cleared when selection changes. | |
| 40 | +| `clearStateOnPrev` | `Boolean/String` | — | When `true` or `'true'`, enables custom navigation buttons and clears state when navigating to the previous step. | |
| 41 | +| `ratingInputs` | `Array` | `[]` | Array of rating input objects containing product configuration data. Supports reusable and non-reusable inputs with `instanceKeys`. | |
| 42 | +| `ratingOptions` | `Object` | `{}` | Rating options passed to the API. Defaults `executePricing` and `executeConfigurationRules` to `true`. | |
| 43 | +| `transactionType` | `String` | — | The transaction type for the rating request | |
| 44 | +| `contextId` | `String` | — | Input property for PATCH first scenario | |
| 45 | + |
| 46 | +Rating inputs and options are based on the [Insurance Product Rating API](https://developer.salesforce.com/docs/atlas.en-us.insurance_developer_guide.meta/insurance_developer_guide/connect_resources_product_rating.htm%20%20). |
| 47 | + |
| 48 | +## HTML Markup |
| 49 | + |
| 50 | +### Side Panel Layout |
| 51 | + |
| 52 | +Displays a tree navigation showing the product hierarchy, allowing users to select products/coverages to configure. |
| 53 | + |
| 54 | +- First product selected as default |
| 55 | +- Selected item highlights and drives the main area content |
| 56 | + |
| 57 | +### Main Section Layout |
| 58 | + |
| 59 | +Shows the selected product's details, attributes (read-only), and associated coverages with their configurable attributes. |
| 60 | + |
| 61 | +**Attribute Details Card:** |
| 62 | +- Displays product title, attributes and price with tax info. |
| 63 | +- Product attributes grouped by category (read-only display) |
| 64 | + |
| 65 | +**Coverages Card (conditional):** |
| 66 | +- Displays if product has coverages |
| 67 | +- When selected, expands to show editable coverage attributes |
| 68 | +- Coverage attributes grouped by category in two-column layout |
| 69 | + |
| 70 | +### Configuration Messages Layout |
| 71 | +- Collapsible message notification area with toggle button |
| 72 | +- Uses the product-configuration-message-item component |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## Component Usage |
| 77 | + |
| 78 | +Embed the productConfiguration LWC in an Omniscript by using the Custom Lightning Web Component element in a step. |
| 79 | + |
| 80 | +### Adding to an OmniScript Step |
| 81 | + |
| 82 | +1. Open your OmniScript in OmniStudio Designer |
| 83 | +2. Add a **Custom Lightning Web Component** element to your step |
| 84 | +3. Set the **LWC Component Name** to `c-product-configuration` |
| 85 | +4. Configure the component properties (see [Public Properties](#public-properties-api)) |
| 86 | + |
| 87 | +If you set `clearStateOnPrev` to `true`, hide the standard Previous and Next buttons in the step by reducing their width to 0\. The productSelection LWC shows Previous and Next buttons for navigation. |
| 88 | + |
| 89 | +### Data Output Structure |
| 90 | + |
| 91 | +The component outputs data to OmniScript via `omniUpdateDataJson()`: |
| 92 | + |
| 93 | +```javascript |
| 94 | +{ contextId: "contextId-123" } |
| 95 | +``` |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## Troubleshooting |
| 100 | + |
| 101 | +### Common Issues |
| 102 | + |
| 103 | +| Issue | Possible Cause | Solution | |
| 104 | +| :---- | :---- | :---- | |
| 105 | +| "No products are available" | Rating API returned no products or ran into error | Verify `rootProductCodes` and `ratingInputs` are correct. | |
| 106 | +| OmniscriptBaseMixin not found on component deployment | Missing Omniscript customization package | Ensure `omniscriptBaseMixin` and utility modules are deployed by following the [Prerequisites](../../../README.md#prerequisites). | |
| 107 | +| Missing context or product details on rating call response | Wrong API version | Ensure that all components and supporting files use Salesforce API version **66.0** or later. | |
| 108 | +| State not persisting | clearStateOnPrev is not set to true | Hide step buttons by setting width to 0 and set `clearStateOnPrev` to true. | |
| 109 | + |
| 110 | +### Debugging |
| 111 | + |
| 112 | +1. **Debug Logs:** Enable debug logs for the `InsuranceRatingApexService` class. |
| 113 | +2. **Browser console:** The component logs errors to the console. |
| 114 | +3. **OmniScript data panel:** Check the data JSON for output values. |
| 115 | + |
| 116 | +## API Version |
| 117 | + |
| 118 | +All components and supporting files must use Salesforce API version **66.0** or later. |
0 commit comments