You need to sign in to do that
Don't have an account?

How to write the soql query with select Owner field statement???
Hi to all.,
I have two objects.,
In one object (Contact details) the fields are firstname ,lastname and Owner.
the second object(View)
I wrote the trigger on View object on after insert.
contact_Details con = [select firstname__c,Lastname__c,owner]
trigger trg_view on View__c (after insert)
{
for(View__c viewobj: Trigger.New)
{
contact_Details__c con = [select id,firstname__c,Lastname__c,owner from contact_Details__c where owner =: CreatedById ];
viewobj.condaetails__c = con.id;
}
}
But this trigger show the error on OWNER FIeld.
then How to compare it and how to write the soql query with select Owner field statement?????
Thanks,
Krishna.
Hi, one more thing... your code is wrong because you can't have a SOQL into a FOR statement. If you try to insert more than 100 records at onces, your code will faild. To avoid this you have to write a bulk trigger (using maps and IN clause, check the documentation for more information).
Regards,
J.