You need to sign in to do that
Don't have an account?
Sree Salesforce
In my requirement when i create parent record i want to create a child record .i have a lookup relationship
trigger createcontacts on Account (after insert) {
list<contact> con=new list<contact>();
list<id> l1=new list<id>();
for(account acc:trigger.new)
{
l1.add(acc.id);
}
if(l1.size()>0 && l1!=null)
{
contact c1=new contact();
c1.accountid=l1.id;
c1.firstname=l1.name;
con.add(c1);
}
insert con;
}
list<contact> con=new list<contact>();
list<id> l1=new list<id>();
for(account acc:trigger.new)
{
l1.add(acc.id);
}
if(l1.size()>0 && l1!=null)
{
contact c1=new contact();
c1.accountid=l1.id;
c1.firstname=l1.name;
con.add(c1);
}
insert con;
}
Shashank (Salesforce Developers)
Are you having a difficulty with this? If so, what is it?
Ramu (Salesforce Developers)
Plese modify the code as below
Sree Salesforce
i unable to crate a reord .i got an error like this Initial term of field expression must be a concrete SObject: LIST<Id> at line 13 column 19
Sree Salesforce
if i run the above code i got an error like Compile Error: Invalid type: list at line 04 column 2
Ramu (Salesforce Developers)
Oops I found that there was a hidden character in my code in the word 'List' something as L*ist. Please copy the below one. I also have done a small correction