if(Trigger.IsBefore &&(Trigger.IsInsert||Trigger.IsUpdate)) {
    for(Account acc:Trigger.New) {
        if(acc.Special_Customer__c == 'VIP' && acc.Customer_Status__c == 'Customer') {
            system.debug('Inside' );
            offList.add(new Offer__c(Name = acc.Name, Account__c = acc.Id,Offer_Level__c = 'NAT'));
        try {
            insert offList;
        catch(Exception e) {
            System.debug('Exception is' + e);


Record is only creating on before update not before insert . Please provide a solution guys !!

  • You can only link the Offer__c records to the Account after insert, since the Account needs to exist already... Jun 24, 2016 at 12:11

2 Answers 2


First understand when to use before and after triggers:

enter image description here This flow basically covers most of the scenarios but not all of them.It says that if you don't know which type of trigger to use, try before trigger first.Because in general they cover 90% of scenarios.

So basically here you need an after insert in place of before insert to create child records.

In before update you already have the id of record(Which is going to be updated), That's why you are able to insert child records.






  • Although i'm not the one who downvoted the post and i too hate if some one downvote without reason so i think the reason is we should try to encourage a behavior of self learning or helping them to clear there concepts rather provide an immediate answer without any description.
    – Mr.Frodo
    Jun 24, 2016 at 13:54
  • @Mr.Frodo haha thank you! "hate" is a big word though, yes I would say "I don't like" if someone downvotes without a reason. I absolutely agree with your note here and your answer too. Since, you have already described the conceptual details in a beautiful way, I didn't feel the need to describe it even more! But I thought, the exact code change the OP needs to make was also important (since I see OP is a newbie)
    – sfdcFanBoy
    Jun 24, 2016 at 14:03

You must log in to answer this question.

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