Skip to content

Commit 21d1eb5

Browse files
authored
Merge pull request #5 from SalesforceLabs/SalesforceLabs/INS/W-21192231/product-configuration-lwc
Init ProductConfiguration LWC in sample apps
2 parents 4fafe29 + 9d39c31 commit 21d1eb5

12 files changed

Lines changed: 3465 additions & 0 deletions

osComponents/ProductConfiguration/classes/InsuranceRatingApexService.cls

Lines changed: 360 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<labels>
4+
<fullName>PRODUCT_CONFIG_MESSAGES</fullName>
5+
<language>en_US</language>
6+
<protected>false</protected>
7+
<shortDescription>Messages</shortDescription>
8+
<value>Messages</value>
9+
</labels>
10+
<labels>
11+
<fullName>PRODUCT_CONFIG_COVERAGES</fullName>
12+
<language>en_US</language>
13+
<protected>false</protected>
14+
<shortDescription>Coverages</shortDescription>
15+
<value>Coverages</value>
16+
</labels>
17+
<labels>
18+
<fullName>PRODUCT_CONFIG_LOADING</fullName>
19+
<language>en_US</language>
20+
<protected>false</protected>
21+
<shortDescription>Loading</shortDescription>
22+
<value>Loading</value>
23+
</labels>
24+
<labels>
25+
<fullName>PRODUCT_CONFIG_PRODUCT_CONFIGURATION</fullName>
26+
<language>en_US</language>
27+
<protected>false</protected>
28+
<shortDescription>Product Configuration</shortDescription>
29+
<value>Product Configuration</value>
30+
</labels>
31+
<labels>
32+
<fullName>PRODUCT_CONFIG_TOGGLE_MESSAGES</fullName>
33+
<language>en_US</language>
34+
<protected>false</protected>
35+
<shortDescription>Toggle Messages</shortDescription>
36+
<value>Toggle Messages</value>
37+
</labels>
38+
<labels>
39+
<fullName>PRODUCT_CONFIG_ERROR</fullName>
40+
<language>en_US</language>
41+
<protected>false</protected>
42+
<shortDescription>Error</shortDescription>
43+
<value>Error</value>
44+
</labels>
45+
<labels>
46+
<fullName>PRODUCT_CONFIG_DETAILS</fullName>
47+
<language>en_US</language>
48+
<protected>false</protected>
49+
<shortDescription>Details</shortDescription>
50+
<value>Details</value>
51+
</labels>
52+
<labels>
53+
<fullName>PRODUCT_CONFIG_SELECT_ITEM_MESSAGE</fullName>
54+
<language>en_US</language>
55+
<protected>false</protected>
56+
<shortDescription>Select Item Message</shortDescription>
57+
<value>Select an item from the tree to see its details.</value>
58+
</labels>
59+
<labels>
60+
<fullName>PRODUCT_CONFIG_PRICE_SUMMARY</fullName>
61+
<language>en_US</language>
62+
<protected>false</protected>
63+
<shortDescription>Price Summary</shortDescription>
64+
<value>Price Summary</value>
65+
</labels>
66+
<labels>
67+
<fullName>PRODUCT_CONFIG_INSTANT_PRICING</fullName>
68+
<language>en_US</language>
69+
<protected>false</protected>
70+
<shortDescription>Instant Pricing</shortDescription>
71+
<value>Instance Pricing</value>
72+
</labels>
73+
<labels>
74+
<fullName>PRODUCT_CONFIG_UPDATE_PRICES</fullName>
75+
<language>en_US</language>
76+
<protected>false</protected>
77+
<shortDescription>Update Prices</shortDescription>
78+
<value>Update Prices</value>
79+
</labels>
80+
<labels>
81+
<fullName>PRODUCT_CONFIG_TOTAL_PREMIUM</fullName>
82+
<language>en_US</language>
83+
<protected>false</protected>
84+
<shortDescription>Total Premium</shortDescription>
85+
<value>Total Premium</value>
86+
</labels>
87+
<labels>
88+
<fullName>PRODUCT_CONFIG_TAXES_FEES_SURCHARGE</fullName>
89+
<language>en_US</language>
90+
<protected>false</protected>
91+
<shortDescription>Taxes Fees Surcharge</shortDescription>
92+
<value>Taxes, Fees and Surcharge</value>
93+
</labels>
94+
<labels>
95+
<fullName>PRODUCT_CONFIG_PREMIUM</fullName>
96+
<language>en_US</language>
97+
<protected>false</protected>
98+
<shortDescription>Premium</shortDescription>
99+
<value>Premium</value>
100+
</labels>
101+
<labels>
102+
<fullName>PRODUCT_CONFIG_ERROR_OCCURRED</fullName>
103+
<language>en_US</language>
104+
<protected>false</protected>
105+
<shortDescription>Error Occurred</shortDescription>
106+
<value>An error occurred</value>
107+
</labels>
108+
<labels>
109+
<fullName>PRODUCT_CONFIG_INVALID_DATA_RECEIVED</fullName>
110+
<language>en_US</language>
111+
<protected>false</protected>
112+
<shortDescription>Invalid Data Received</shortDescription>
113+
<value>Invalid data received</value>
114+
</labels>
115+
<labels>
116+
<fullName>PRODUCT_CONFIG_SELECT_COVERAGE_FIRST</fullName>
117+
<language>en_US</language>
118+
<protected>false</protected>
119+
<shortDescription>Select Coverage First</shortDescription>
120+
<value>Please select the coverage first.</value>
121+
</labels>
122+
<labels>
123+
<fullName>PRODUCT_CONFIG_DELETE</fullName>
124+
<language>en_US</language>
125+
<protected>false</protected>
126+
<shortDescription>Delete</shortDescription>
127+
<value>Delete</value>
128+
</labels>
129+
<labels>
130+
<fullName>PRODUCT_CONFIG_CONFIRM_DELETE</fullName>
131+
<language>en_US</language>
132+
<protected>false</protected>
133+
<shortDescription>Confirm Delete</shortDescription>
134+
<value>Confirm Delete</value>
135+
</labels>
136+
<labels>
137+
<fullName>PRODUCT_CONFIG_DELETE_CONFIRMATION_MESSAGE</fullName>
138+
<language>en_US</language>
139+
<protected>false</protected>
140+
<shortDescription>Delete Confirmation Message</shortDescription>
141+
<value>Are you sure you want to delete?</value>
142+
</labels>
143+
<labels>
144+
<fullName>PRODUCT_CONFIG_CANCEL</fullName>
145+
<language>en_US</language>
146+
<protected>false</protected>
147+
<shortDescription>Cancel</shortDescription>
148+
<value>Cancel</value>
149+
</labels>
150+
<labels>
151+
<fullName>PRODUCT_CONFIG_CONFIRM</fullName>
152+
<language>en_US</language>
153+
<protected>false</protected>
154+
<shortDescription>Confirm</shortDescription>
155+
<value>Confirm</value>
156+
</labels>
157+
<labels>
158+
<fullName>PRODUCT_CONFIG_REQUIRED_ATTRIBUTES_MSG</fullName>
159+
<language>en_US</language>
160+
<protected>false</protected>
161+
<shortDescription>Required Attributes Message</shortDescription>
162+
<value>Complete the required fields.</value>
163+
</labels>
164+
<labels>
165+
<fullName>PRODUCT_CONFIG_NO_ATTRIBUTES_MSG</fullName>
166+
<language>en_US</language>
167+
<protected>false</protected>
168+
<shortDescription>No Attributes Message</shortDescription>
169+
<value>No attributes to show.</value>
170+
</labels>
171+
<labels>
172+
<fullName>PRODUCT_CONFIG_MULTI_VALUE_DECODER_MESSAGE</fullName>
173+
<language>en_US</language>
174+
<protected>false</protected>
175+
<shortDescription>Multi Value Decoder Message</shortDescription>
176+
<value>Shows the value in the format</value>
177+
</labels>
178+
<labels>
179+
<fullName>PRODUCT_CONFIG_NEXT</fullName>
180+
<language>en_US</language>
181+
<protected>false</protected>
182+
<shortDescription>Next</shortDescription>
183+
<value>Next</value>
184+
</labels>
185+
<labels>
186+
<fullName>PRODUCT_CONFIG_PREVIOUS</fullName>
187+
<language>en_US</language>
188+
<protected>false</protected>
189+
<shortDescription>Previous</shortDescription>
190+
<value>Previous</value>
191+
</labels>
192+
<labels>
193+
<fullName>PRODUCT_CONFIG_TAX_AMOUNT</fullName>
194+
<language>en_US</language>
195+
<protected>false</protected>
196+
<shortDescription>Tax Amount</shortDescription>
197+
<value>Tax Amount</value>
198+
</labels>
199+
</CustomLabels>
200+
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
| `ProductConfigurationLabels.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+
| `clearStateOnPrev` | `Boolean/String` || When `true` or `'true'`, enables custom navigation buttons and clears state when navigating to the previous step. |
40+
| `ratingInputs` | `Array` | `[]` | Array of rating input objects containing product configuration data. Supports reusable and non-reusable inputs with `instanceKeys`. |
41+
| `ratingOptions` | `Object` | `{}` | Rating options passed to the API. Defaults `executePricing` and `executeConfigurationRules` to `true`. |
42+
| `transactionType` | `String` || The transaction type for the rating request |
43+
| `contextId` | `String` || Input property for PATCH first scenario |
44+
45+
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).
46+
47+
## HTML Markup
48+
49+
### Side Panel Layout
50+
51+
Displays a tree navigation showing the product hierarchy, allowing users to select products/coverages to configure.
52+
53+
- First product selected as default
54+
- Selected item highlights and drives the main area content
55+
56+
### Main Section Layout
57+
58+
Shows the selected product's details, attributes (read-only), and associated coverages with their configurable attributes.
59+
60+
**Attribute Details Card:**
61+
- Displays product title, attributes and price with tax info.
62+
- Product attributes grouped by category (read-only display)
63+
64+
**Coverages Card (conditional):**
65+
- Displays if product has coverages
66+
- When selected, expands to show editable coverage attributes
67+
- Coverage attributes grouped by category in two-column layout
68+
69+
### Configuration Messages Layout
70+
- Collapsible message notification area with toggle button
71+
- Uses the product-configuration-message-item component
72+
73+
---
74+
75+
## Component Usage
76+
77+
Embed the productConfiguration LWC in an Omniscript by using the Custom Lightning Web Component element in a step.
78+
79+
### Adding to an OmniScript Step
80+
81+
1. Open your OmniScript in OmniStudio Designer
82+
2. Add a **Custom Lightning Web Component** element to your step
83+
3. Set the **LWC Component Name** to `c-product-configuration`
84+
4. Configure the component properties (see [Public Properties](#public-properties-api))
85+
86+
If you set `clearStateOnPrev` to `true`, hide the standard Previous and Next buttons in the step by reducing their width to 0\. The productConfiguration LWC shows Previous and Next buttons for navigation.
87+
88+
### Data Output Structure
89+
90+
The component outputs data to OmniScript via `omniUpdateDataJson()`:
91+
92+
```javascript
93+
{ contextId: "contextId-123" }
94+
```
95+
96+
---
97+
98+
## Troubleshooting
99+
100+
### Common Issues
101+
102+
| Issue | Possible Cause | Solution |
103+
| :---- | :---- | :---- |
104+
| "No products are available" | Rating API returned no products or ran into error | Verify `ratingInputs` are correct. |
105+
| OmniscriptBaseMixin not found on component deployment | Missing Omniscript customization package | Ensure `omniscriptBaseMixin` and utility modules are deployed by following the [Prerequisites](../../../README.md#prerequisites). |
106+
| 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. |
107+
| State not persisting | clearStateOnPrev is not set to true | Hide step buttons by setting width to 0 and set `clearStateOnPrev` to true. |
108+
109+
### Debugging
110+
111+
1. **Debug Logs:** Enable debug logs for the `InsuranceRatingApexService` class.
112+
2. **Browser console:** The component logs errors to the console.
113+
3. **OmniScript data panel:** Check the data JSON for output values.
114+
115+
## API Version
116+
117+
All components and supporting files must use Salesforce API version **66.0** or later.

0 commit comments

Comments
 (0)