+ Start a Discussion

How to create RECORD in an object2 when Record is created in object1 (trigger/ apex class)?

I am trying to autopopulate record for Object2 when record is created in object1. I am writing a trigger adapted from https://help.salesforce.com/apex/HTViewSolution?id=000176618&language=en_US The trigger throws no error, but no Transaction Record is created when Journal record is created. Journal has lookup relation with Transaction object & all required fields for both object has been included. What am i missing?
trigger Post8 on Journal__c (AFTER insert) { List <Transaction__c> vehToInsert = new List <Transaction__c>(); for (Journal__c o : Trigger.new) { Transaction__c v = new Transaction__c (); v.Description__c = o.Description__c; v.Reference__c = o.Reference__c; vehToInsert.add(v); }try { insert vehToInsert; } catch (system.Dmlexception e) { system.debug (e); }}
SandhyaSandhya (Salesforce Developers) 

Please check if your trigger is in Active mode.Try to put system.Debugs at the top of the trigger and see if it gets fired.and also put System.Debug before and after insert DML statement.

Hope this helps you!

Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
Thanks and Regards