You need to sign in to do that
Don't have an account?
naveen reddy 68
issue on trigger without showing any error
I need to query new records after inserting a record but my below trigger doesnt show any error but even doesnt display any records either please suggest me
trigger con1 on Contact (before insert,before update)
{
Map<id,Name> MP = new Map<id,Name>();
for(Contact con:Trigger.new)
{
if(con.LastName != null)
{
con.Title = 'kelly1';
}
if(con.Title == 'kelly1')
{
list<contact> c1=[select id,lastName From Contact where id=:trigger.NewMap.keyset()];
system.debug(c1);
}
}
}
trigger con1 on Contact (before insert,before update)
{
Map<id,Name> MP = new Map<id,Name>();
for(Contact con:Trigger.new)
{
if(con.LastName != null)
{
con.Title = 'kelly1';
}
if(con.Title == 'kelly1')
{
list<contact> c1=[select id,lastName From Contact where id=:trigger.NewMap.keyset()];
system.debug(c1);
}
}
}
If you need to use record ids u need to use after trigger,
Try this code,
Let me know if it solved
All Answers
Can you please elaborate your requirement in detail?
First of all, we shouldn't do DML operations(Update, Delete, Insert, Queryies) in for loop. Let me know your requirement, so that I can help you.
If you need to use record ids u need to use after trigger,
Try this code,
Let me know if it solved
What error u looking for and what is your senioroi .
Explain me i hope i can help you .
Regards,
Harish.R.