You need to sign in to do that
Don't have an account?

Before Trigger
Hi,
I have written this trigger to append 'Dr' prefix for al lead names.but i am getting some error.Please help me.
"Error: Compile Error: expecting a semi-colon, found 'Name' at line 6 column 27"
trigger PrefixDoctor on Lead (before insert,before update) {
for(Lead l :trigger.new)
{
List<Lead> leadlist=new List<Lead>();
{
l.First Name='Dr.'+l.First Name ;
}
}
}
I have written this trigger to append 'Dr' prefix for al lead names.but i am getting some error.Please help me.
"Error: Compile Error: expecting a semi-colon, found 'Name' at line 6 column 27"
trigger PrefixDoctor on Lead (before insert,before update) {
for(Lead l :trigger.new)
{
List<Lead> leadlist=new List<Lead>();
{
l.First Name='Dr.'+l.First Name ;
}
}
}
Please use the below code:
I tested the above code and it is working properly.
With your code, every time you update the Lead, it will prefix the Dr.
Please do let me know if it helps you.
Regards,
Mahesh
All Answers
Please use the below code:
I tested the above code and it is working properly.
With your code, every time you update the Lead, it will prefix the Dr.
Please do let me know if it helps you.
Regards,
Mahesh
I have tried this trigger,but i am getting some error .
Error: Compile Error: No such column 'Account' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 9 column 17
trigger accountupdate on Account (before update) {
for(Account a:trigger.new)
{
List<Account> a1=[select AccountNumber,Name from Account where Name=:a.Name];
if(a1.size>0)
{
if(a.SLA__c=='gold')
{
List<Contact> c=[select Phone from Contact where Contact.Account=:a.Name];
if(c.size>0)
{
a.count_c=c.size();
}
}
if(a1.size==0)
{
}
}
}
}
Please find the corrected code:
FYI, I just corrected the errors but didn't fix the bulkification. You still need to work on bulkifying the above code as it will not work if you update 100+ Accounts.
Regards,
Mahesh
I have tried this codeand it is working,but i have a question ,is this trigger exactly doing this??----whenever i am creating Accounts with SLA 'gold' the no of phone numbers from contact object of all account will be populated in Account custom object Count.Am i Right??