function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
S Balaji 8S Balaji 8 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

For the following code i am getting insert failed exception on insert contentList; Can someone help me with this , it is working on one sandbox but failing in another one

@isTest public static void sendemailtoAccountownerTest(){
        
        Test.startTest();
        //Create Document Parent Record
      
        Account acc =new Account();
        acc.Name = 'Test Account';
        acc.BillingCountryCode = 'CA';
        insert acc ;
        
        //Create Document
        ContentVersion cv = new ContentVersion();
        cv.Title = 'Test Document';
        cv.PathOnClient = 'TestDocument.pdf';
        cv.VersionData = Blob.valueOf('Test Content');
        cv.IsMajorVersion = true;
        Insert cv;
        
        //Get Content Documents
        Id conDocId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cv.Id].ContentDocumentId;
        
        system.debug('conDocId data is :'+conDocId);
        bynder__Bynder_Asset__c bynder = new bynder__Bynder_Asset__c();
        bynder.bynder__File_Type__c = 'DOCUMENT';
        bynder.bynder__Asset_Id__c = 'Test';
        insert bynder;
        
        //Create ContentDocumentLink 
        List<ContentDocumentLink> contentList = new List<ContentDocumentLink>();
        ContentDocumentLink cdl = New ContentDocumentLink();
        cdl.LinkedEntityId = acc.Id;
        cdl.ContentDocumentId = conDocId;
        cdl.shareType = 'V';
        contentList.add(cdl);
        
        ContentDocumentLink cdl1 = New ContentDocumentLink();
        cdl1.LinkedEntityId = bynder.Id;
        cdl1.ContentDocumentId = conDocId;
        cdl1.shareType = 'V';
        contentList.add(cdl1);
        system.debug('Content list data is :' + contentList);
        insert contentList;
           
        bynder.bynder__Content_Version_Id__c = contentList[0].Id;
        update bynder;
        
        MOD_ContentDocumentLinkTriggerHelper.sendEmailToAccountOwner(contentList);
        Test.stopTest();
    }
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Balaji,

Can you specify on which line you are facing the error so can suggest based on it.

Thanks,