The RecordTypeMapper application uses field values on new Lead records to determine which record type the new Lead should have.
This version of the app uses custom settings to control which record type to use, based on values from the Lead's Country and Industry fields.
This repo is structured as a Salesforce DX project and is ready to be pushed to scratch organizations using the Salesforce DX Command Line Interface tool. For more information on developing with DX: https://developer.salesforce.com/platform/dx
- Clone this repo and navigate to it in the terminal or VS Code.
- Make sure you have authenticated with a Salesforce developer hub org. (To sign up a trial: https://developer.salesforce.com/promotions/orgs/dx-signup)
- Create a new scratch organization using the project-scratch-def.json definition in this project.
sfdx force:org:create -f config/project-scratch-def.json -a myCsOrg
- Open the scratch org.
sfdx force:org:open -u myCsOrg
- Create custom setting records in the scratch org by executing the apex in
anonApexScripts/runPostInstall.txt
sfdx force:apex:execute --apexcodefile anonApexScripts/runPostInstall.txt
- Navigate to Leads. Try creating Leads where the Country and Industry values match mappings in the
RecordTypeMapping__ccustom setting, and notice that the record type is set automatically by theTriggerRecordTypeMappingtrigger after save.