You need to sign in to do that
Don't have an account?
Lukesh Karmore
simple trigger but stuck in relating custom field
create custom field on account (client contact lookup to contact)
when account is insert ,contact is also inserted with same name
and that contact will be client contact on account
when account is insert ,contact is also inserted with same name
and that contact will be client contact on account
Try Below Trigger Please Mark It As Best Answer If It Helps
Thank You!
trigger AccountsClientContact on Account (after insert) {
list<contact> conlist=new list<contact>();
list<id> myid=new list<id>();
string accname;
string phone;
string email;
id conid;
for(Account acc:Trigger.new){
myid.add(acc.id);
accname=acc.name;
phone=acc.phone;
email=acc.email__c;
conid=acc.clientContact__c;
}
contact con=new contact();
con.firstname='test';
con.lastname=accname;
con.accountId=myid[0];
con.phone=phone;
con.email=email;
con.Id=conid;
conlist.add(con);
insert conlist;
}
The Error is con.Id field Is not Writeable As It Is Generated By System It Self Please Mark It As Best Answer If It Helps
Thank You!
I've Made Some Changes In Trigger It Will Work Now Please Let Me Know If It Work And Mark It As Best Answer If It Helps
Thank You!