You need to sign in to do that
Don't have an account?
ruchika Nayyar
Once an account insert a contact will create with the name of account and that contact will be the client contact on Account
how i write this code?
explain me???
explain me???
Please try below code:
Hope this will help you, let me know if you still need assistance on this.
Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com
i have Create a field on Account Named (Client Contact lookup to Contact)
how i will do this that contact will be the client contact on Account???
trigger accountcontact on Account (after insert) {
if(trigger.isinsert){
list<contact> ct= new list<contact>();
for(account acc:Trigger.new){
contact c= new contact();
c.LastName=acc.name;
c.AccountID=acc.ID;
c.MailingStreet=acc.BillingStreet;
c.MailingCity=acc.BillingCity;
c.MailingCountry=acc.BillingCountry;
c.Phone=acc.Phone;
c.Email=acc.myruchika__email1__c;
c.ID=acc.myruchika__client_contact__c;
ct.add(c);
}
insert ct;
}
}
Firstly, Account - Contact relationship is master (Account) - Detail (Contact) i.e. for single Account we could have multiple contacts. Which contact we need to put as client.
Thanks,
Gaurav
Please add new trigger on Contact object, below is the code: Also, please remove "c.ID=acc.myruchika__client_contact__c;". We cannot set "ID" field.
Hope this will help you.
Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com