You need to sign in to do that
Don't have an account?
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
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;
}
In my requirement when i create parent record i want to create a child record .i have a lookup relationship
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
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;
}
Here is the code for your requirement,
All Answers
{
contact c1=new contact();
c1.accountid=l1[0].id;
c1.firstname=l1[0].name;
con.add(c1);
}
insert con;
}
Here is the code for your requirement,