0

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){
    domain.add(l.domain__c);
  }

  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){
      contactsByDomain.put(a.domain__c,a);
  }

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

1 Answer 1

2

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:

domain.removeAll(Domain_Blacklist__c.getAll().keySet());

You must log in to answer this question.

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