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
Lakshmi PalnatiLakshmi Palnati 

​Unable to publish any Library as getting error message related to triggers.

Hi,

I am trying to upload a file from Library and getting below error message: 

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger IntranetContents_ShareWithOtherLibrary caused an unexpected exception, contact your administrator: IntranetContents_ShareWithOtherLibrary: execution of AfterUpdate caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Class.Content_Sharing_Required_Readings.createRequiredReadingSharRecords: line 21, column 1".

Any suggestions?

Thanks in advance.



 
logontokartiklogontokartik
From the brief description above I am guessing there is a trigger on the IntranetContents_ShareWithOtherLibrary, (is it a custom object?) If yes, there is definitely a malicious query that querying some object that has large amount of data in your org. What would be helpful is to find the trigger and paste the code in the trigger if possible.

Best.
 
Lakshmi PalnatiLakshmi Palnati
Here is the code :

This trigger fires when contentversion Upload/update (its 205 lines of code,Just pasted till line 21). 

trigger IntranetContents_ShareWithOtherLibrary on ContentVersion (after update,before update) {
              
        set<ID> contentDocuments = new Set<ID>();
        Set<ID> documentIds = new Set<ID>();
        map<Id, ContentVersion> createReadingRecordsNewMap;
        map<Id, ContentVersion> createReadingRecordsOldMap;
        set<String> teams = new set<String>();
        static final list<String> masterLibrariesNames = new list<String>{'*VX Master','*VX Master Secure'};
        //get *VX Master and *VX Master Secure libraries
        map<Id,ContentWorkspace> contentsDir = new map<Id,ContentWorkspace>([Select ID from ContentWorkspace Where Name in:masterLibrariesNames]);
              
        if(contentsDir.size() > 0){
            for(ContentVersion ver : trigger.new){
                documentIds.add(ver.ContentDocumentId);
            }           
            for(ContentWorkspaceDoc workspace : [Select Id,ContentDocumentId From ContentWorkspaceDoc
                                                 Where ContentDocumentId IN :documentIds AND ContentWorkspaceId in: contentsDir.keySet()]){
                contentDocuments.add(workspace.ContentDocumentId);  
            }
        }


------------------------

Even When deleting the file from content detail page getting similar error message:

trigger IntranetRemoveRequiredReadings on ContentDocument (after delete) {
    list<Intranet_Required_Reading__c> deletedRRRecordsList = new list<Intranet_Required_Reading__c>();
    Set<ID> ContentVersionIDs = new Set<ID>();
    
    for(ContentDocument conDoc:trigger.old){
         ContentVersionIDs.add(conDoc.LatestPublishedVersionId);
    }
  
    for(Intranet_Required_Reading__c RRRecord : [select Id from Intranet_Required_Reading__c where ContentVersionID__c in:ContentVersionIDs]){
        deletedRRRecordsList.add(RRRecord);
    }   
        
    if(!deletedRRRecordsList.isEmpty()){
        delete deletedRRRecordsList;
    }
}

Thanks in advance!