+ Start a Discussion
reddygari403reddygari403 

regarding trigger

Hi

 

 

 how can we write a trigger using list,set ,map for two custom objects.the trigger should be in the way ,,when we insert a record in one object ,the record should automatically inserted in the second  object.at the same time when we update the record in first object.the record should automatically update in the second object...i.e.there should not be any relation between two objects.

RustanRustan

Create an after insert trigger for the first object to create the second object record when a first object record is created. When the second object record is created, make sure that there is a field with the  id of the first object record.

 

Then create an after update trigger where it queries all second record object and put in a list all that have the first object record id. Create some logic to update the second record object with the new values of the first record object.

Jia HuJia Hu
You can create a Trigger on Object A,
and when you insert a Record of A, in the Trigger of A, you can create a Record of Object B.

and when you update a Record of A, in the Trigger A, you can use SOQL to query the Object B and find out which Record you have to update at the same time.