0

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);
}}
3
  • What is the error that you are receiving?
    – Mahmood
    Commented Nov 16, 2016 at 11:44
  • No error & no trigger fire
    – Tanmoy Das
    Commented Nov 16, 2016 at 12:02
  • Put a "system.debug();" statement right at the top of your trigger to see if the trigger is firing or not.
    – Mahmood
    Commented Nov 16, 2016 at 12:04

1 Answer 1

0

Please try this

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(Description__c = o.Description__c,
                            Reference__c=o.Reference__c);
        vehToInsert.add(v);
    }
    try {
        insert vehToInsert; 
    } 
    catch (system.Dmlexception e) {
        system.debug (e);
    }
}
5
  • I tried this too. no Transaction is created
    – Tanmoy Das
    Commented Nov 16, 2016 at 11:26
  • try putting debugs in between and then let us know where the code broke.Do check if your trigger is getting fired or not?
    – Samir
    Commented Nov 16, 2016 at 14:36
  • Is your trigger active?
    – Samir
    Commented Nov 17, 2016 at 9:01
  • Yes, the trigger is active, & i find no error anywhere. So, as the trigger is not working, I have developed a Action by process builder, & the functionality achieved.
    – Tanmoy Das
    Commented Nov 17, 2016 at 10:22
  • That's good.But i am really interested in knowing why your trigger is not getting fired.Could you please try changing your event to Before Insert?
    – Samir
    Commented Nov 17, 2016 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .