This repository contains a Lightning Web Component (LWC) built for a Salesforce Digital Experience site. The component is a form that creates cases for subscription cancellation requests, with form fields displayed based on the locale.
The Locale-Based LWC Form allows users to submit a subscription cancellation request through a form that is conditionally displayed based on the locale
URL parameter. The form includes fields like email address, order number, desired termination date, and reason for termination, and it automatically creates a case in Salesforce with predefined values such as record type, status, and origin.
To run this project and deploy it to your Salesforce org, you will need:
- Salesforce CLI: Ensure you have the latest version of the Salesforce CLI installed.
- Node.js: Required if you are using Node.js dependencies or testing tools.
-
Install Salesforce CLI:
-
Verify the installation:
sfdx --version
First, clone the repository to your local machine:
git clone https://github.com/yourusername/locale-based-lwc-form.git
cd locale-based-lwc-form
Before deploying, you need to authorize a Salesforce org (e.g., sandbox or production):
-
Authorize your staging sandbox:
sfdx auth:web:login --setalias staging --instanceurl https://test.salesforce.com
-
Authorize your production org:
sfdx auth:web:login --setalias production --instanceurl https://login.salesforce.com
After you've authorized your org, you can deploy the code to your Salesforce org.
sfdx project deploy start --source-dir force-app --target-org staging
When deploying to production, ensure that you convert the source format to metadata format, and only run the relevant test class for deployment:
-
Convert the source format to metadata format:
sfdx force:source:convert --rootdir force-app --outputdir mdapi_output_dir
-
Deploy the converted metadata to production and only run the required test class:
sfdx force:mdapi:deploy --deploydir mdapi_output_dir --targetusername production --testlevel RunSpecifiedTests --runtests CancelSubscriptionControllerTest
-
Monitor the deployment:
You can monitor the status of your deployment using:
sfdx force:mdapi:deploy:report --targetusername production
- After deployment, navigate to your Salesforce Digital Experience site in Experience Builder.
- Add the
cancelSubscriptionForm
component to a page by dragging it from the component list. - Publish the site and ensure the form appears when the URL contains the
language=de
parameter.
If the deployment fails due to missing fields or incorrect configuration, ensure that:
- All required fields (e.g.,
SuppliedEmail
,RS_Order_Number__c
) exist on the Case object. - The
RecordTypeId
provided in the Apex controller matches an existing record type on the Case object.
If you have any questions or issues, feel free to reach out to the project maintainer.
Matt R (matt@tala.dev)
- 1.0
- Initial release with form and case creation logic.
- Includes locale-based rendering and required fields for case creation.
This project is licensed under the MIT License.