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

Trigger to insert data from one Object to another Object
Hi,
I have two objects. Object1 and Object2.
I have 10 fields in object1. After creating a record in object1, I want to create a record in Object2.
I want only 3 field values from Object1.
If anyone have code syntax, please share.
Thanks in Advance
Regards,
Hari
I have two objects. Object1 and Object2.
I have 10 fields in object1. After creating a record in object1, I want to create a record in Object2.
I want only 3 field values from Object1.
If anyone have code syntax, please share.
Thanks in Advance
Regards,
Hari
Hi hari
This senario done by using Triggers
Let Us consider
Object 1 - Account
Object 2 - contact
Write trigger on account object(after insert)
TRIGGER:
Trigger objecttgr on Account(after insert){
List<contact> cons =new List<contact>();
for(Account a :trigger.new){
contact c =new contact();
c.lastname = a.name;
c.phone = a.phone;
//slly we can match the fileds of both objects, what are required fileds u want before going to insert of contact
c.accountid = a.id;
cons.add(c);
}
insert cons;
}
All Answers
Replace in below code to your object api names write on object 1 .
Any issue ask me .
Regards ,
Harish.R
Hi hari
This senario done by using Triggers
Let Us consider
Object 1 - Account
Object 2 - contact
Write trigger on account object(after insert)
TRIGGER:
Trigger objecttgr on Account(after insert){
List<contact> cons =new List<contact>();
for(Account a :trigger.new){
contact c =new contact();
c.lastname = a.name;
c.phone = a.phone;
//slly we can match the fileds of both objects, what are required fileds u want before going to insert of contact
c.accountid = a.id;
cons.add(c);
}
insert cons;
}
How to compare today i.e., Friday with some field in IF loop
while runing the problem because last name field is mandatory