+ Start a Discussion

Custom object relationships - creation and deletion

I have custom upload object, which I use to import the business data (accounts, contacts, opportunities) into this object using APEX data loader from excel.


I have a trigger on 'after insert' on this custom upload object, that calls custom APEX classes for accounts, contacts and opportunities. When I execute the upload,  the trigger executes sucessfully, the custom object record gets inserted however none of the other objects - account, contact or opportunities get created.


I dont see any errors in the debug log, it says the insert is sucessful and 3 rows updated but I dont see any account, contacts & opportunities.


Any thoughts why this could be? Do I need a lookup relationship from the custom object to account, contact & opportunities to be able to create those?

Shashikant SharmaShashikant Sharma

Triggers should work from data loader as well, Please check you trigger does not handles the bulk data properly. please share your trigger code. I would suggest you to upload a single record from data loader then check your trigger works or not.


Thanks much. Here is my trigger code & createAccounts method in my APEX AccountHelper classes. The other methods AccountHelper class of seemed to be working fine because I tested them in the debugger with Finest and all the data is in there. Even the Database insert .isSuccess returns true however when I log into my org the records are not there.


trigger InsertAccountContactOpportunity on BatchOpportunity__c (after insert) {
    List <BatchOpportunity__c> newBatchOpportunities = trigger.new;
      Map<String, List<Account>> accountList = AccountHelper.extractAccounts(newBatchOpportunities);
       AccountHelper accHelper = new AccountHelper(accountList);




    public void createAccounts(){
        this.accounts = assignAccountOwner(this.accounts);
        List <Account> accountsToInsert = new List<Account>();
        for(String accountOwner:accounts.keySet()){
            List<Account> newAccounts = accounts.get(accountOwner);
            for (Account account:newAccounts){
        if(accountsToInsert.size() > 0){
            for(Account account:accountsToInsert){
                System.debug('Account Name - ' + account.Name);
            Database.SaveResult[] insertResults = Database.insert(accountsToInsert, false);
                    System.debug('Records for Accounts inserted successfully');
            }else{System.debug('Records for NOT successfully');


It looks like my trigger is not firing! I dont know the reasons why the trigger would not get fired.


I have a static method in my class not sure if thats a cause