You need to sign in to do that
Don't have an account?
shekhar 46
trigger on account to check no contact associated and then create dummy contact
Write a trigger whenever account created, no contact is associated to that account, create dummy contact with contact name as account name. need to check no contact is associated with it and then create dummy contact
Yes, the trigger is perfectly correct and you followed best practice as well by writing dml out of For loop.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
As per process when Account is getting created there is no chance of contact availale relted to that Account. So you mean a dummy contact should be created every time account is created?
Thanks,
Can u tell me my code is right for above scneario
trigger inserttrigger on account(after insert){
list<contact> listcon= new list<contact>();
for (account A: trigger.new){
contact C =new contact();
c.accountID=A.id;
c.firstnam='test';
c.lastname=A.name;
listcon.add(c);
}
insert listcon;
}
Yes, the trigger is perfectly correct and you followed best practice as well by writing dml out of For loop.
If this solution helps, Please mark it as best answer.
Thanks,