You need to sign in to do that
Don't have an account?
sri sfdc
Trigger on lead object
when ever rating is hot on lead object , I want to create Accout and Contact for that lead. As a new bie, I don't know how to get that lead id to create account ,contact .
kindly help me in this.
Amit:- I added this line so that evey time in update case it will not create new Account and Contact. Code will create record only once you will change Rating on Lead object. Code will work even for update just try to change rating.
IF you want to create every time one contact and account remove above check
2. if(listAccountToCreate.size() > 0 ) , if(listContactToCreate.size() > 0 ) why we need to mention these two if conditions
Amit:- IF Event will not change or Rating will not hot in that case above both list will blank and we dnt need to create new record
Same code will work for insert and update as well.
In case of update you need to change Rating from hot to some other and again back to hot, OR you can change code like below if you want to create record every time
Let us know if this will help you
All Answers
1) http://amitsalesforce.blogspot.in/2015/06/trigger-best-practices-sample-trigger.html
Let us know if this will help you
Hi Amit,
Thanks for help. Kindly explain few points.
1. led.Rating != OldLead.Rating can u explain this condition
2. if(listAccountToCreate.size() > 0 ) , if(listContactToCreate.size() > 0 ) why we need to mention these two if conditions.
And doing some modifications in above trigger I wrote it for before insert event it works . when I am trying to do for both events before insert and after update its not working. So can u suggest me for both insert and update .
Amit:- I added this line so that evey time in update case it will not create new Account and Contact. Code will create record only once you will change Rating on Lead object. Code will work even for update just try to change rating.
IF you want to create every time one contact and account remove above check
2. if(listAccountToCreate.size() > 0 ) , if(listContactToCreate.size() > 0 ) why we need to mention these two if conditions
Amit:- IF Event will not change or Rating will not hot in that case above both list will blank and we dnt need to create new record
Same code will work for insert and update as well.
In case of update you need to change Rating from hot to some other and again back to hot, OR you can change code like below if you want to create record every time
Let us know if this will help you