You need to sign in to do that
Don't have an account?
Gita Borovsky
Trying to figure out last bit of Trigger
Hi,
I've got this Trigger on Leads:
trigger UpdateLeadOwner on Lead (before insert) {
for (Lead leadInLoop : Trigger.new) {
// Retrieve owner from Account record based on email domain name
list <Account> acct = [Select OwnerId from Account WHERE Domain_1__c = :leadInLoop.Domain__c Limit 2];
if (acct.size() == 1) {
System.debug('account owner id is: ' + acct[0].OwnerId);
leadInLoop.OwnerId=acct[0].OwnerId;
}
}
}
I need to update the trigger so that the Lead source field "LeadSource" does not contain either of these picklist values, "Contact Us" or "Reprint" but I can't figure out where it should go. Help, please? Thanks!
I've got this Trigger on Leads:
trigger UpdateLeadOwner on Lead (before insert) {
for (Lead leadInLoop : Trigger.new) {
// Retrieve owner from Account record based on email domain name
list <Account> acct = [Select OwnerId from Account WHERE Domain_1__c = :leadInLoop.Domain__c Limit 2];
if (acct.size() == 1) {
System.debug('account owner id is: ' + acct[0].OwnerId);
leadInLoop.OwnerId=acct[0].OwnerId;
}
}
}
I need to update the trigger so that the Lead source field "LeadSource" does not contain either of these picklist values, "Contact Us" or "Reprint" but I can't figure out where it should go. Help, please? Thanks!
if (leadInLoop.LeadSource != 'Contact Us' && leadInLoop.LeadSource != 'Reprint') {
Forgot to declare the field in which the value should not be equal to Contact Us or Reprint.
Hope that helped!
Thanks!
All Answers
Are you wanting to hide the picklist values from the field LeadSource. If so, you could use recordtypes to do so.
Please let me know what your actual requirement is so that I can better assist you.
Thanks!
You just need to put the condition on when to fire the trigger. Try the code below:
trigger UpdateLeadOwner on Lead (before insert) {
for (Lead leadInLoop : Trigger.new) {
if (leadInLoop != 'Contact Us' && leadInLoop != 'Reprint') {
// Retrieve owner from Account record based on email domain name
list <Account> acct = [Select OwnerId from Account WHERE Domain_1__c = :leadInLoop.Domain__c Limit 2];
if (acct.size() == 1) {
System.debug('account owner id is: ' + acct[0].OwnerId);
leadInLoop.OwnerId=acct[0].OwnerId;
}
}
}
}
Thanks!
if (leadInLoop.LeadSource != 'Contact Us' && leadInLoop.LeadSource != 'Reprint') {
Forgot to declare the field in which the value should not be equal to Contact Us or Reprint.
Hope that helped!
Thanks!