function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
V AnandV Anand 

how to use lookup relation in triggers?

Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference:

 

Trigger chekaccount on contac(before insert)

{

                contact con=trigger.new[0];

                if(con.accountid!=null)

                {

                                integer i= [select count() from contact where accountid=:con.accountid];

                                if(i>0)

                                {

                                                trigger.addError('you can\'t add this contact');

                                }

                }

}

 

Note: contact has a lookup with account.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

V AnandV Anand

k..

 

I want to use lookup datatype in triggers ..?

 

and my task is check whether new lead is belongs to particular QUEUE or not?

 

please help me to achieve above........... 

balaji malemarpurambalaji malemarpuram

you need to query leads by comparing queue id.Queue id comes from Group .