Hi Vikas,
Try this:
trigger trigsetLastName on Contact (after insert,after update)
{
Map<id,account> parentacc = new Map<id,account>();
Set<id> listids = new Set<id>();
for( contact childobj :Trigger.new)
{
listids.add(childobj.accountid); // error in this line
}
parentacc= new map<id,account> ([select id,Name ,(select id,LastName from contacts) from account where id in: listids]);
for ( contact c :trigger.new)
{
account myacc = parentacc.get(c.accountid);
myacc.Name=c.LastName;
}
Update parentacc.values();
}
Thanks