• Abhishek Bansal
  • ALL STAR
  • 8771 Points
  • Member since 2015
  • Software Developer
  • Metacube Softwares Pvt Ltd


  • Chatter
    Feed
  • 287
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 1434
    Replies
I need to be able to make a list of accounts and an opportunity within each newly created account. What's the most efficient way to do this?

Currently, my plan is to create a List<Account> and do a Database.insert() then for each Id, add an opportunity to List<Opportunity> then do another Database.insert().

Is there a better way?
Hello, I am no developer, but I am trying to turn off an existing apex class by just commenting it out. I'm able to do that, and when I push it into production, I keep getting an error realted to the actual apex class: 

System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: []
Stack Trace: Class.NewcostsheetwithapprovalTest.testallmethodwithNoInitialvaluesET: line 563, column 1

Any suggestions on removing the error?

First line of apex class: 

public class NewcostsheetwithapprovalTest
{    
/*
  
I need help creating an alert to an account/opportunity so the owner of the account or opportunity receives an alert if they haven't touched the account (phone or email) in 30 days.
Hello Guys

I need a small help, I am trying to design an aura component for my client where he needs to access the content documents while creating the new case, I have overridden the button and tried to show the aura component with Dynamic search functionality, Now my Issue is that when i search with the keyword,  I am not getting the documents with Preview and hyperlink options,I have referred several website links but could not find the solution

https://sfdcmonkey.com/2018/10/29/open-files-lightning-component/

https://www.forcetalks.com/blog/implementation-of-dynamic-search-in-lightning-component/

My Component
 
<aura:component controller="FilesListApexController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:actionOverride" access="global">
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchListOfRecordTypes}"/>
    
    <aura:attribute name="lstOfRecordType" type="String[]" />
    <aura:attribute name="isOpen" type="boolean" default="false" />
    <div style="font-size: 30px;">
    <div class="slds-align_absolute-center">Welcome to the Case Portal</div>
    </div>
     <h1 class="slds-page-header__title slds-m-right_small slds-align-middle slds-truncate"  title="Case Help Documents">Please click the below button to create a New Case</h1>
  <div class="slds-m-around--x-large">
    <lightning:button label="Create a Case" onclick="{!c.openModal}" />
  </div>   
    
    <h1 class="slds-page-header__title slds-m-right_small slds-align-middle slds-truncate"  title="Case Help Documents">Case Help Documents</h1>
   <!-- Model Box Start -->    
    <aura:if isTrue="{!v.isOpen}">
        <div role="dialog" tabindex="-1" aria-labelledby="header43" class="slds-modal slds-fade-in-open">
            <div class="slds-modal__container">
                <div class="slds-modal__header">
                    <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.closeModal}">
                        X<span class="slds-assistive-text">Cancel</span>
                    </button>
                    <h2 id="header43" class="slds-text-heading--medium">New Case</h2>
                </div>
                
                <div class="slds-modal__content slds-p-around--medium">
                    <div class="slds-grid slds-wrap">
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                             <div class="slds-align--absolute-center">Select a Record Type</div>                            
                        </div>
                        <div class="slds-size--1-of-2 slds-large-size--1-of-2">
                            <ui:inputSelect aura:id="selectid">
                                <aura:iteration items="{!v.lstOfRecordType}" var="Cases__c">                            
                                    <ui:inputSelectOption text="{!Cases__c}" label="{!Cases__c}"  />
                                </aura:iteration>
                            </ui:inputSelect>
                        </div>&nbsp; &nbsp;
                    </div>                  
                </div>
                
                <div class="slds-modal__footer">
                    <lightning:button class="slds-button slds-button--neutral" onclick="{!c.closeModal}">Cancel</lightning:button>
                    <lightning:button class="slds-button slds-button--brand" onclick="{!c.createRecord}">Next</lightning:button>
                </div>
            </div>
        </div>
        <div class="slds-backdrop slds-backdrop--open"></div>
    </aura:if>
    
    <aura:attribute name="Documents" type="List" />
    <aura:attribute name="key" type="String" /> 
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />        
    <lightning:input type="text" name="searchKey" aura:id="searchKey" onchange="{!c.searchKeyChange}" placeholder="Search" />          
    <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
        <thead>
            <tr class="slds-text-heading_label">              
                <th scope="col"><div class="slds-truncate" title="Name">Title</div></th>
                <th scope="col"><div class="slds-truncate" title="File Type">FileType</div></th>         
                <th scope="col"><div class="slds-truncate" title="Created By">Created By</div></th>            
            </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.Documents}" var="Document">
                <tr>  
                    <td><div class="slds-truncate" title="{!Document.Title}">{!Document.Title}</div></td>
                    <td><div class="slds-truncate" title="{!Document.Type}">{!Document.FileType}</div></td>                   
                    <td><div class="slds-truncate" title="{!Document.CreatedBy.Name}">{!Document.CreatedBy.Name}</div></td>                    
                </tr>
            </aura:iteration>
        </tbody>
    </table>    
    
    <aura:if isTrue="{!v.hasModalOpen}">
        <section onclick="{!c.closeModel}"
                 role="dialog"
                 aria-modal="true"
                 class="slds-modal slds-fade-in-open">
            <div class="slds-modal__container">
                <div class="slds-modal__content slds-p-around_medium slds-text-align_center"
                     style="background: transparent;">
                    <div style="width: 50%; margin: 0 auto; text-align: left">
                        <!--<lightning:fileCard> to preview file using content document Id -->
                        <lightning:fileCard fileId="{!v.Documents}"/>
                    </div>
                </div>
            </div>
        </section>
        <div class="slds-backdrop slds-backdrop_open"></div>
    </aura:if>
    
    
</aura:component>

My Controller
 
({
    
    /* On the component Load this function call the apex class method,
    * which is return the list of RecordTypes of object
    * and set it to the lstOfRecordType attribute to display record Type values
    * on ui:inputSelect component. */
    
    fetchListOfRecordTypes: function(component, event, helper) {
        var action = component.get("c.fetchRecordTypeValues");
        action.setCallback(this, function(response) {
            component.set("v.lstOfRecordType", response.getReturnValue());
        });
        $A.enqueueAction(action);
    },
    
    /* In this "createRecord" function, first we have call apex class method
    * and pass the selected RecordType values[label] and this "getRecTypeId"
    * apex method return the selected recordType ID.
    * When RecordType ID comes, we have call  "e.force:createRecord"
    * event and pass object API Name and
    * set the record type ID in recordTypeId parameter. and fire this event
    * if response state is not equal = "SUCCESS" then display message on various situations.
    */
    createRecord: function(component, event, helper) {
        component.set("v.isOpen", true);
        
        var action = component.get("c.getRecTypeId");
        var recordTypeLabel = component.find("selectid").get("v.value");
        action.setParams({
            "recordTypeLabel": recordTypeLabel
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var createRecordEvent = $A.get("e.force:createRecord");
                var RecTypeID  = response.getReturnValue();
                createRecordEvent.setParams({
                    "entityApiName": 'Cases__c',
                    "recordTypeId": RecTypeID
                });
                createRecordEvent.fire();
                
            } else if (state == "INCOMPLETE") {
                var toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    "title": "Oops!",
                    "message": "No Internet Connection"
                });
                toastEvent.fire();
                
            } else if (state == "ERROR") {
                var toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    "title": "Error!",
                    "message": "Please contact your administrator"
                });
                toastEvent.fire();
            }
        });
        $A.enqueueAction(action);
    },
    
    closeModal: function(component, event, helper) {
        // set "isOpen" attribute to false for hide/close model box
        component.set("v.isOpen", false);
    },
    
    openModal: function(component, event, helper) {
        // set "isOpen" attribute to true to show model box
        component.set("v.isOpen", true);
    },
    
    doInit: function(component, event, helper) {
        helper.getDocumentList(component);
    },
    searchKeyChange: function(component, event) {
        var searchKey = component.find("searchKey").get("v.value");
        console.log('searchKey:::::'+searchKey);
        var action = component.get("c.findByTitle");
        action.setParams({
            "searchKey": searchKey
        });
        action.setCallback(this, function(a) {
            component.set("v.Documents", a.getReturnValue());
        });
        $A.enqueueAction(action);
    },   
     getSelected : function(component,event,helper){
        // display modle and set seletedDocumentId attribute with selected record Id   
        component.set("v.hasModalOpen" , true);
        component.set("v.Documents" , event.currentTarget.getAttribute("data-Id")); 
        
    },
    closeModel: function(component, event, helper) {
        // for Close Model, set the "hasModalOpen" attribute to "FALSE"  
        component.set("v.hasModalOpen", false);
        component.set("v.Documents" , null); 
    },
    
    doInit : function(component, event, helper) {
        var action = component.get("c.getDocuments");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set('v.Documents', response.getReturnValue());
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
                else if (state === "ERROR") {
                    var errors = response.getError();
                    if (errors) {
                        if (errors[0] && errors[0].message) {
                            console.log("Error message: " + 
                                        errors[0].message);
                        }
                    } else {
                        console.log("Unknown error");
                    }
                }
        });
        $A.enqueueAction(action);  
    },
    getSelected : function(component,event,helper){
        // display modle and set seletedDocumentId attribute with selected record Id   
        component.set("v.hasModalOpen" , true);
        component.set("v.Documents" , event.currentTarget.getAttribute("data-Id")); 
        
    },
    closeModel: function(component, event, helper) {
        // for Close Model, set the "hasModalOpen" attribute to "FALSE"  
        component.set("v.hasModalOpen", false);
        component.set("v.Documents" , null); 
    },
    
})

My Helper
 
({      
    getDocumentList: function(component) {
        var action = component.get('c.getDocuments');
        var self = this;
        action.setCallback(this, function(actionResult) {
            component.set('v.Documents', actionResult.getReturnValue());
        });
        $A.enqueueAction(action);
    }
})

My Apex codee
 
public class FilesListApexController {
    
    @AuraEnabled
    public static Cases__c getsharechatcases(String recordId){
        Cases__c c = [SELECT Id,Name,Status__c,Parent_cases__c,OwnerId,Priority__c,Email__c,
                      RecordTypeId,Problem_Description__c,Internal_comments__c,Asset_category__c,Case_closed_date__c,Other_Software_Details__c FROM Cases__c WHERE Id =: recordId];
        return c;
    }
    public static Map<Id, String> recordtypemap {get;set;}
    
   @AuraEnabled        
    public static List<String> fetchRecordTypeValues(){
        List<Schema.RecordTypeInfo> recordtypes = Cases__c.SObjectType.getDescribe().getRecordTypeInfos();    
        recordtypemap = new Map<Id, String>();
        for(RecordTypeInfo rt : recordtypes){
            if(rt.getName() != 'Master')
            recordtypemap.put(rt.getRecordTypeId(), rt.getName());
        }        
        return recordtypemap.values();
    }
    
    @AuraEnabled
    public static Id getRecTypeId(String recordTypeLabel){
        Id recid = Schema.SObjectType.Cases__c.getRecordTypeInfosByName().get(recordTypeLabel).getRecordTypeId();        
        return recid;
    }
    @AuraEnabled
    public static List <contentDocument> getDocuments(Id arecordId) {
        List<ContentDocumentLink> CDLs = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :arecordId];
        if (CDLs.size() < 1) return new List<ContentDocument>(); 

        // Make a List of ContentDocument IDs
        List <Id> CDIdList = new List <Id> ();
        for (ContentDocumentLink nextCDL : CDLs) {
            CDIdList.add(nextCDL.ContentDocumentId); }        

        List<ContentDocument> entries = [SELECT Id, Title, FileType FROM ContentDocument WHERE ContentDocument.Id IN :CDIdList];
        return entries;
    }
        
    @AuraEnabled
    public static List<contentDocument> findByTitle(String searchKey) {
        String Title =  + searchKey + '%';
        List<contentDocument> DocList = [Select id,Title,FileType,CreatedBy.Name,ContentSize From contentDocument WHERE Title LIKE :Title];
        return DocList;
    }
}

My Error Snapshot

User-added imageI need Preview, hyperlink, and download options just like we do in the files object​​​​​​​
 
Hi,

I am trying to query SObjectType field from Duplicate Record Set object but getting below error
No such column 'SObjectType' on entity 'DuplicateRecordSet'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."

here is the dev refrence for that field https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_duplicaterecordset.htm.

Salesforce Support is also not much helpful. Has any one had this issue? If any one can help it would be great

 
Hi all, if anyone spot what is the cause of in the following code error?
debug log tells me that is "argument can not be null."

User-added image
and it seems it null pointer exception issue in the loop of for (Billing__c due : dueBillings) part, but not sure what can fix this.

The logic is Apex Controller is called by controller.js fetchDueBalance method, pass the return value to the controller.js, then set component dueBalance (Decimal) in the component.

Apex Controller
@AuraEnabled
    public static Decimal fetchDueBalance(Id recordId) {
        // check which object started the apex class
        Decimal dueBalance;
        String sObjName = recordId.getSObjectType().getDescribe().getName();
        List<Billing__c> dueBillings = new List<Billing__c>();
        System.debug('dueBlalance: initial point: ' + dueBalance); //passed

        if (sObjName == 'Billing__c') {
            Billing__c bl = [
            SELECT Id, Case__c
            FROM Billing__c 
            WHERE Id =:recordId
            LIMIT 1
            ];

            dueBillings = [
                SELECT Id, Due_Balance__c
                FROM Billing__c
                WHERE Case__c = :bl.Case__c AND Due_Balance__c !=0 AND User_Due_Date__c < :Date.today()
                ORDER BY User_Due_Date__c ASC
            ];
            System.debug('dueBlalance: list search: ' + dueBalance); // passed

            if (dueBillings != null){
                System.debug('dueBlalance: nullcheck: ' + dueBalance); // passed
                dueBalance = 0;

                for (Billing__c due: dueBillings) {
                    dueBalance += due.Due_Balance__c;

                    System.debug('dueBlalance: loop point: ' + dueBalance); /passed
                }
            }
        }     
    return dueBalance;
    }
It passes to the final debug log, but not returning the dueBalance value (Decimal) to the component via controller.

Component
<aura:component controller="BillingCheckController" implements="force:hasRecordId,force:appHostable,flexipage:availableForAllPageTypes">
   <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
   <aura:attribute name="recordId" type="Id" />
   <aura:attribute name="dueBalance" type="Decimal" />
   <aura:attribute name="billings" type="Billing__c[]" description="store accounts with there child contacts"/>
   
   <h1><lightning:formattedNumber value="{!v.dueBalance}"></lightning:formattedNumber></h1>
Controller.js
({
    doInit: function(component, event, helper) {
       //call apex class method
        var recordId = component.get("v.recordId");
        var action = component.get('c.fetchBillings');
        action.setParams({recordId :recordId});
        action.setCallback(this, function(response) {
            var state = response.getState();
                if (state === "SUCCESS") {
                    component.set('v.billings', response.getReturnValue());
                }
        });
        $A.enqueueAction(action);

        /* action1 for the sumup number of the overdue billings */
        var recordId = component.get("v.recordId");
        var action = component.get('c.fetchDueBalance');
        action.setParams({recordId :recordId});
        action.setCallback(this, function(response) {
            //store state of response
            var state = response.getState();
                if (state === "SUCCESS") {
                    component.set('v.dueBalance', response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
})
Help me sleep...

 
Hello,
I am unable to fix the error 
System.NullPointerException: Attempt to de-reference a null object on my trigger.

Could someone help?
Thanks
 
trigger Knowledge_kavKnownErrorSubscription on Knowledge__kav (after insert, after update) {
    
    List<Known_Error_Subscription__c> kesList = new List<Known_Error_Subscription__c>();
    
    for(Knowledge__kav kav : [SELECT KnowledgeArticleId, Known_Error_Status__c, VersionNumber, (SELECT Knowledge__c FROM Known_Errors_Subscriptions__r)
                              FROM Knowledge__kav WHERE Id IN :Trigger.New]) {
                                                                              
            if(kav.KnowledgeArticleId != null && (Trigger.oldMap.get(kav.Id).LastPublishedDate != Trigger.newMap.get(kav.Id).LastPublishedDate)) {
            Known_Error_Subscription__c kes = kav.Known_Errors_Subscriptions__r;
            kes.Knowledge__c = kav.KnowledgeArticleId;
            kesList.add(kes);
            
        }
                                  
    }
    if(kesList.size() > 0) {
        update kesList;
    }
    

}

 
Can user create a record If he don't have access on object and executing apex class(Creates new record on that object) having with sharing keyword?

Hello, I am writing a trigger with the following requirements:

 

Write a trigger that automatically sets Tasks to the “Completed” status whenever their associated Leads are set to any Closed status. Make sure your trigger is bulkified - there should be no SOQL queries inside any loops.


I have written the following trigger - it works well if the task is 'Closed - Not Converted' however when I convert the lead, the task is not closing. Can you provide some guidance please?

 

 

trigger SetTaskCompletedOnLeadClosed on Lead (after update) {
//Create a set of ideas for no duplicates
    Set<Id> leadListIds = new Set<Id>();
    for(Lead l : Trigger.new){
    // Access the "old" record by its ID in Trigger.oldMap     
        if(l.status == 'Closed - Converted' || l.status == 'Closed - Not Converted'){
            leadListIds.add(l.id);
            system.debug('LeadListIds = '+leadListIds);
            }
        }
    
    List<Task> taskList = [SELECT id, subject, status, whoid FROM Task WHERE whoid in :leadListIds];
    system.debug('taskList = '+taskList);
    
    List<Task> taskToUpdate = new List<Task>();
    for(Task t : taskList){
        if(t.status != 'Completed'){
            t.status = 'Completed';
        }
         taskToUpdate.add(t);
         system.debug('taskToUpdate = '+taskToUpdate);
    }
    if(taskToUpdate.size()>0){
    update taskToUpdate;
    }
}
List<String> newMultiSelectList = new List<String>();

newMultiSelectList.add('Pro-Life'); newMultiSelectList.add('Establishment'); newMultiSelectList.add('GOP');

string value = '('' + String.join(newMultiSelectList, '','')+'')';

// I need results that includes all the three values (AND Condition)

//I tried this, but it is taking as OR condition

String queryString = 'select id, Audience_Tags__c FROM Audience__c WHERE Audience_Tags__c INCLUDES'+value;
List<Audience__c> newlist = DataBase.query(queryString); system.debug('List of records: '+newlist);

Any help would be appreciated
I have a custom object for an "Application" and each application has an evaluator (Lookup to user table). I want all files uploaded to be owned by the evaluator since other users might upload files but it's annoying that the actual evaluator can't delete them unless they have "Modify All Data" permissions. They also don't automatically attach to AdobeSign agreements because they are not owned by the senter. I wrote this trigger and it seems to work but when you try to upload the file, it gives you an error message in Salesforce, despite the log having no indication of an error. If  I change the trigger to "after insert" instead of "before insert" the file uploads successfully but the owner doesn't change. 
 
trigger CDL_OwnershipUpdate2021 on ContentDocumentLink (before insert) {

    for(ContentDocumentLink CDL: trigger.New)
    { 
        string parentId = CDL.LinkedEntityId;
        string newOwner = null;
        string docId = CDL.ContentDocumentId;
        
        List<Application__c> Apps = new List<Application__c>();
        
        Apps = [select Id, Evaluator__c from Application__c where Id = :parentId];
        
        if(Apps != null && Apps.size() > 0){
            
            System.debug('Checkpoint 1');
            
            for(Application__c app: Apps)
            {
                newOwner = app.Evaluator__c;
            }
        }
        
        ContentDocument doc = [select Id, OwnerId from ContentDocument where Id = :docId];
        
        if(newOwner != null){
            
            System.debug('Checkpoint 2');
            
            doc.OwnerId = newOwner;
            
            update doc;
        }   
    }
}

 
I'm using the following code:


global class SendNotificationBatch implements Database.Batchable<sObject>, Schedulable, Database.Stateful { //Variable Section global FINAL String strQuery; global List<String> errorMessages = new List<String>(); global SendNotificationBatch() { this.strQuery = getBatchQuery(); } //Returns the Query String to Batch constructor to fetch right records. private String getBatchQuery() { String strQuery = 'SELECT Id, CloseDate, Owner.Email FROM Opportunity WHERE CloseDate < TODAY'; return strQuery; } //Batch Start method global Database.QueryLocator start(Database.BatchableContext BC) { return Database.getQueryLocator(strQuery); } //Batch Execute method calls findCostForWoD method global void execute(Database.BatchableContext BC, List<sObject> scopeList) { System.debug(LoggingLevel.INFO, '== scopeList size ==' + scopeList.size()); List<Opportunity> oppList = (List<Opportunity>) scopeList; if(!oppList.isEmpty()) { List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>(); for (Opportunity prod : oppList) { Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {prod.Owner.Email}; Message.setToAddresses(toAddresses); Message.SaveAsActivity = false; mailList.add(Message); } if(!mailList.isEmpty()) { try{ Messaging.sendEmail(mailList); } catch (Exception ex) { errorMessages.add('Unable to send email to Tech: '+ ex.getStackTraceString()); } } } } //Batch Finish method for after execution of batch work global void finish(Database.BatchableContext BC) { AsyncApexJob aaj = [Select Id, Status, NumberOfErrors, JobItemsProcessed, MethodName, TotalJobItems, CreatedBy.Email from AsyncApexJob where Id =:BC.getJobId()]; // Send an email to the Apex job's submitter notifying of job completion. Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {aaj.CreatedBy.Email}; mail.setToAddresses(toAddresses); mail.setSubject('JOB Salesforce Send Notification Batch: ' + aaj.Status); String bodyText='Total Job Items ' + aaj.TotalJobItems + ' Number of records processed ' + aaj.JobItemsProcessed + ' with '+ aaj.NumberOfErrors + ' failures.\n'; bodyText += 'Number of Error Messages ' + errorMessages.size() + '\n'; bodyText += 'Error Message' + String.join(errorMessages, '\n'); mail.setPlainTextBody(bodyText); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } //Method which schedules the ProductDownloadBatch global void execute(SchedulableContext sc) { SendNotificationBatch snInstance = new SendNotificationBatch(); ID batchprocessid = Database.executeBatch(snInstance); } }

but I get this error when executing:

Error MessageUnable to send email to Tech: Class.SendNotificationBatch.execute: line 41, column 1

I'm assuming it has to do with opportunity products, when I just want to look at the CloseDate field on the Opportunity object. Any ideas on what to change?  Thanks!
Is there a way to set the ownerId = Content version> email> Case>Last Modified By?

I want to set the owner of the file to whoever has been working the case. These files are created via email-to-case. Please help with actual suggestions, not links. I have been reading blogs for days and nothing has worked. I'm at wits end on how to allow my users to delete Files on emails.

trigger ConDoc on ContentVersion (after insert) {

    List<ContentVersion> conver = [SELECT Id, Title, OwnerId FROM ContentVersion WHERE Id IN: Trigger.newMap.keySet()];

    for (ContentVersion CV: conver){
        CV.OwnerId= '3D00GF0000007fwJR';
        CV.Title = 'HannaTest';
    }

    update conver;

}
I Keep failing this challenge for the below reason:
The user's profile was not set to System Administrator

Here is my screen shot of my users profile Please what am I doing to fail this?
User-added image
 

Hi All,

Here by i'm adding my trigger & triggerHandler class that i have written. Can anybody give me TestClass for this?Urgent reply needed.
Trigger
_------------------
trigger CaseTrigger on Case (after undelete, before delete, before insert, after update) {

    CaseTriggerHandler handler = new CaseTriggerHandler();    

    //Delete related action plans
    if (trigger.isdelete ){
        handler.OnBeforeDelete(trigger.old);        
    }    
    //Undelete related action plans
    else if (trigger.isUnDelete ){
        handler.OnAfterUndelete(trigger.new);       
    }
    // deleting the cases if Delete_Case__c sets to true
    else if (trigger.isUpdate && trigger.isAfter){        
        handler.OnAfterUpdate(trigger.new);
    }
}

/*********************************************************************************
CaseTriggerHandler  class:
----------------------------------------------
public without sharing class CaseTriggerHandler {
     List<Case>          deleteCasesList     =     new list<case>();
     // constructor
     public CaseTriggerHandler(){}     
     // Call on after update trigger to delete all cases where Delete_Case__c is true
     public void OnAfterUpdate(List<Case> ListCase){         
         for( Case c : ListCase){
                 // if Delete case is true add this record to list
                 if(c.Delete_Case__c){
                    Case c1=new Case(Id=c.Id);
                    deleteCasesList.add(c1);
                 }
            }
            // deleting the list items 
            if(deleteCasesList != null && deleteCasesList.size()>0){            
                 delete deleteCasesList;
            }
     }
     // Call on Before Delete trigger on Case Object
     public void OnBeforeDelete(List<Case> ListCase){     
        set<ID>             cIds    = new set<ID>();
        List<String>        apIds   = new List<String>();
        List<ActionPlan__c> deletePermantently_apIds= new List<ActionPlan__c>();       
        for( Case c : ListCase ){
            cIds.add( c.Id );
        }
        
        /* GET Action Plans to delete from recycle bin */
        deletePermantently_apIds = [ select Id, Name , LastModifiedDate from ActionPlan__c where Case__c in : cIds and isDeleted = true ALL ROWS ];
        
        if ( deletePermantently_apIds.size() >0 ){          
            Database.emptyRecycleBin(deletePermantently_apIds);
        }           
        
        //Get all action plans associated with Campaigns
        for( Case a : [Select (Select Id From Action_Plans__r) From Case a where Id in : cIds]){
            if (a.Action_Plans__r.size() >0 ){
                for(ActionPlan__c ap :a.Action_Plans__r ){
                    apIds.add(ap.Id);
                }
            }
        }
        if ( apIds.size() >0 ){
            ActionPlansBatchDelete aPBatch = new ActionPlansBatchDelete(apIds, Userinfo.getUserId());
            Database.ExecuteBatch( aPBatch );       
        }
    }
    // Call on After Undelete trigger on Case Object
    public void OnAfterUndelete(List<Case> ListCase){    
        set<ID>             cIds    = new set<ID>();           
        for( Case c : ListCase){
            cIds.add( c.Id );
        }
        list <ActionPlan__c> aPs = [ select Id from ActionPlan__c where Case__c in : cIds ALL ROWS ];
        
        try{
            if(ActionPlanObjectTriggerTest.isTest){
                //throw dmlException
                insert new Contact();   
            }
            //undelete aPs;
            Database.undelete( aPs,false);
        } catch ( Dmlexception e ){
            for (Case c: ListCase){
                c.addError('You can not undelete an action plan whose related object is deleted.');
            }
        }
    }
    
}