+ Start a Discussion
suresh143suresh143 

I need Trigger Example

Once i have created record in account object and automatically created releted list contact  record created how to achive this 

hitesh90hitesh90

Hi suresh,

 

Below is the sample trigger for your requirement.

 

Apex Trigger:

trigger trgCreateContact on Account (after insert) {
	List<Contact> lstCon = new List<Contact>();
    for(account a:trigger.new){
        Contact objCon=new Contact();
        objCon.LastName = 'value which you give';
		objCon.Accountid = a.id;
        lstCon.add(objCon);
    }
	if(lstCon.size() > 0){
		insert lstCon;
	}
}

 

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/