I have wrote code assign lead to existing account owner on the basis of incoming domain name.

I want to bypass the code for specific domain.

How can I add a custom setting which will hold all the domain which I want to bypass.

Can anyone help?

trigger addContact on Lead (before insert){

  Set<string> domain = new Set<string>();

  For (lead l:trigger.new){

  List<Contact> leadContactIds = [Select Id, OwnerId, domain__c FROM Contact WHERE domain__c IN: domain];

  Map<String, Contact> contactsByDomain=new Map<String, Contact>();

  for (Contact a:leadContactIds){

  for (Lead l2:trigger.new){
      l2.ownerId = contactsByDomain.get(l2.domain__c).ownerid;

1 Answer 1


You can create a List Custom Setting with no custom fields. Name it Domain_Blacklist__c and use the Name field to hold blacklisted values. Then you would just remove the blacklist from your Set<String> already collected:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .