Help writing an Apex Trigger within our Salesforce that will route new Leads to specified salesperson
We would like to create a trigger in Salesforce that will route certain incoming leads that have pre-specified email domain convention(s) to the appropriate account owner (salesperson) of the corresponding company, which will assign them as a lead owner.
For example, we have Lead A that has an email domain of @comcast.net ([email protected]), we know we want all leads that have @comcast.net to be assigned to Sales Person: Jon. So anytime a lead is created in Salesforce with an @comcast.net domain (it can be leadB or leadC) they will automatically be assigned to Salesperson Jon.
We will provide the mapping email convention to sales leads, we need your help to write the java for the trigger within our Salesforce instances.
LeadRoutingRule__c
- custom settings objectDomains__c
(textarea) - Domains list, delimeted with\n
UserId__c
(text) - User to route thses domains
LeadRoutingRulesController
- helps to manageLeadRoutingRule__c
objects from Lightning controllersLeadTriggerHandler
- trigger, do main logic
APEX coverage 100%, tests include main corner-cases.
LeadRoutingRules
- Settings componentLeadRoutingRulesForm
- Form for the settings componentLeadRoutingRuleUpdated
- An event to notify a main component about singe item changesNameById
- Universal component to convert an id of something to name