• Ashu sharma 38
  • NEWBIE
  • 100 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 93
    Questions
  • 84
    Replies
Hi,

I have written an schedule class,in which when I run in production,it threw an error caused by: System.LimitException: Too many query rows: 50001

 line 25, column 1

 public void execute(SchedulableContext sc){
        
        list<lead> myFive9LeadList=[ select id,name,Originating_System__c,createdDate,Call_Center_Disposition_Date__c,Call_Center_Disposition_Details__c from lead where Originating_System__c='Five9' AND createdDate >:X15MinutesAgo];
        list<lead> mySparkroomLeadList=[ select id,name,Originating_System__c,createdDate from lead where Originating_System__c='Sparkroom' AND createdDate >:X15MinutesAgo];

//Line 25
        list<lead> myLeadListDispositions=[ select id,name,Originating_System__c,createdDate from lead where Call_Center_Disposition_Details__c='Transfer' AND Call_Center_Disposition_Date__c >:X15MinutesAgo];
        
        
        //For No Lead from Five9
        if(myFive9LeadList.size()==0 ){
            system.debug('Five9 List Size'+ myFive9LeadList.size());
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(toAddresses );
            mail.setCcAddresses(ccAddresses);
            mail.setSubject('Notification:: No Lead from Five9');
            String messageBody = '<html><body>Hi, &nbsp;&nbsp;&nbsp;</body> <br/> Last 15 minutes no lead generated from Five9.<br/>Please look into Five9 lead process and make sure that it is working fine.<br/><br/>Thanks </html>


Thanks..





 
Hi,
I am getting 41% code coverage in my apex controller.

public class ContactTaskOnApplication {
    
    @AuraEnabled
    public static List<Task> getContactTask(Id recordId,String contactAPIName){
        
        if(recordId==null || contactAPIName==null){
            return null;     
        }
        String sObjName = recordId.getSObjectType().getDescribe().getName();
        string query='SELECT Id, ' +contactAPIName+ ' FROM '+sObjName+ ' WHERE Id=:recordId';
        List<sObject> sObjectList=database.query(query);
        
        system.debug('sObjectList ' +sObjectList);
        
        if (!sObjectList.isEmpty()){
            id contactId=(Id)sObjectList[0].get(contactAPIName);
            List<Task> tsk=[SELECT Id,Subject,Priority,ActivityDate,Due_Date__c,
                            whoId FROM task WHERE whoId=:contactId];
            system.debug('tsk '+tsk);
            return tsk;
        }
        return null;
    }
    
}

Test class
====
@isTest
public class TestContactTaskOnApplication {
    
    public static Account partnerAccount;
    public static Contact studentContact;
    public static Application__c application;
    public static RFI__c rfi;
    public static Task task;
    
    static testmethod void testContactTaskOnApplicationMethod() {
        try{
            Id idRecordId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Educational_Institution').getRecordTypeId();
            
            //Insert Account
            partnerAccount = new Account(Name='Gwendwyr Test', RecordTypeId=idRecordId);
            insert partnerAccount;
            
            //Insert Contact
            studentContact = new Contact(LastName='Someguy', firstname='Someguy' , email='test@test.com',hed__Citizenship__c='Canada');  
            insert studentContact;
            
            //Insert Application
            application=new Application__c(Contact__c=studentContact.id,Partner_Account_Application__c=partnerAccount.id);
            insert application;
            
               //Insert RFI
                rfi= new RFI__c (Email__c='testrfi@somerfi.com',Last_Name__c='Test RFI',First_Name__c='Test RFI',Contact__c=studentContact.id );
                insert rfi;
            
            //Insert Task
            task=new Task(Subject='Call',whoId=studentContact.id,ActivityDate=system.today(),Priority ='Normal',Due_Date__c=system.today()-1);
            insert task;
           
            ContactTaskOnApplication.getContactTask(application.id,application.Contact__c);
            ContactTaskOnApplication.getContactTask(rfi.id,rfi.Contact__c);
            
            //application.id, application.Contact__c
        }
        catch(exception e){
            
        }
        
    }
}
Hi,

I have created a component for dispalyng list of records in page where use icon for collapse and expansion,but when i click on icon all records are dispalying but i want to show only single record should display when click on that.


<aura:component controller = "appC" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="sObjectName" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="newTask" type="Task" default="{'sobjectType':'Task'}"/>
    <aura:attribute name="tasks" type="Task[]" default="{'sobjectType' : 'Task'}"/>
    
    <ul class="slds-timeline"> 
        <div class="isExpendable slds-timeline__item_expandable slds-timeline__item_task" aura:id="expId">  
            <aura:iteration items="{!v.tasks}" var="item" >
                
                <div class="slds-media ">
                    <div class="slds-media__figure">
                        <button class="slds-button slds-button_icon"
                                onclick="{!c.toggleAcitivity}"
                                title="test"
                                aria-controls="task-item-base">
                            <lightning:icon iconName="utility:switch" 
                                            size="x-small"
                                            class="slds-button__icon slds-timeline__details-action-icon" />
                        </button> 
                        
                        <div class="slds-icon_container" title="task">
                            <lightning:icon iconName="standard:task" size="small"/>
                        </div>
                    </div>
                    
                    <div class="slds-media__body">
                        <div class="slds-grid slds-grid_align-spread slds-timeline__trigger">
                            <div class="slds-grid slds-grid_vertical-align-center slds-truncate_container_75 slds-no-space">
                                <h3 class="slds-truncate" title="{!item.Subject}">
                                    <strong>{!item.Subject}</strong>
                                </h3>
                            </div>
                        </div>
                        
                        <p class="slds-m-horizontal_xx-small">
                            <lightning:formattedDateTime value="{!item.ActivityDate}"/> 
                        </p>
                        
                        <!-- expandable section start-->
                        <article class="slds-box slds-timeline__item_details slds-theme_shade slds-m-top_x-small slds-m-horizontal_xx-small"
                                 id="task-item-base"
                                 aria-hidden="true">
                            <ul class="slds-list_horizontal slds-wrap">
                                <li class="slds-grid slds-grid_vertical slds-size_1-of-2 slds-p-bottom_small">
                                    <span class="slds-text-title slds-p-bottom_x-small">Priority</span>
                                    <span class="slds-text-body_medium slds-truncate" title="{!item.Priority}">{!item.Priority}</span>
                                </li>
                                <li class="slds-grid slds-grid_vertical slds-size_1-of-2 slds-p-bottom_small">
                                    <span class="slds-text-title slds-p-bottom_x-small">Status</span>
                                    <span class="slds-text-body_medium slds-truncate" title="{!item.Status}">{!item.Status}</span>
                                </li>
                                <li class="slds-grid slds-grid_vertical slds-size_1-of-2 slds-p-bottom_small">
                                    <span class="slds-text-title slds-p-bottom_x-small">Subject</span>
                                    <span class="slds-text-body_medium slds-truncate" title="{!item.Subject}">{!item.Subject}</span>
                                </li>
                                <li class="slds-grid slds-grid_vertical slds-size_1-of-2 slds-p-bottom_small">
                                    <span class="slds-text-title slds-p-bottom_x-small">Due Date</span>
                                    <span class="slds-text-body_medium slds-truncate" title="{!item.Due_Date__c }">{!item.Due_Date__c}</span>
                                </li>
                            </ul>
                        </article>
                        
                    </div>
                </div>
            </aura:iteration>
        </div>
        
    </ul>
    
</aura:component>
JS.
 toggleAcitivity : function(component, event, helper) {
        $A.util.toggleClass(component.find('expId'), 'slds-is-open');
Hi,

I am trting to populate the contacts task in my application object,but I am trying to passng the contactId ,confuse over it how to do.
Kindly suggest!!!!

Here is my code.

 public static list<Task> getContactTask(string contactId){
  list<task> contactTask=new list<task>();
        list<contact> consList=[select id,name,(select id from applications__r) from contact where id=:contactId];
       list<Task> tsk=[select id,whoId from task where whoId=:consList[0].id];
        system.debug('Task' +tsk);
        return tsk;
}
}

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes"
                access="global" controller="ContactActivityHistory">
    
    <aura:attribute name="recordId" type="Id"/>
   
    <aura:attribute name="newTask" type="Task" default="{'sobjectType':'Task'}"/>
    <aura:attribute name="tasks" type="Task[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <aura:iteration items="{!v.tasks}" var="item">
        {!item.Subject}, {!item.ActivityDate}<br/>
    </aura:iteration>
    
</aura:component>


Js.
({
    
    doInit : function(component, event, helper)
    {
        console.log('Test activity');
        var action = component.get("c.getContactTask");
        console.log('Test Activity @@@@');
        // var action=component.get('v.recordId');
        console.log(component.get("v.recordId")); 
        action.setParams({            
            ContactId : component.get('v.recordId')
        });
        
        console.log('Test my contact record activity ' +component.get('v.recordId'));
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS"){
               // var records = response.getReturnValue();
               // console.log('Server-> ' + JSON.stringify(records));
                alert("From server: " + response.getReturnValue());
                var newItems=[];
                for (var i=0; i< records.length; i++)
                {
                    var record = records[i];
                    console.log('record-> ' + JSON.stringify(record));
                    
                    //   var Item = {title: record.Name, id: record.Id, status: "Unassigned"};
                    //  console.log('Item-> ' + JSON.stringify(Item));
                    
                    newItems.push(record);
                    console.log('newItems-> ' + JSON.stringify(newItems));
                }
                component.set("v.tasks", newItems);
                
                
            } 
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                }
                
            }            
            
        });
        $A.enqueueAction(action);
        
        
    }  
})


Thanks
 
Hi,

I have created a component to show the contact activity in my object.

public class ContactActivityHistory {
    
    @auraEnabled
    
    public static list<Task> getContactTask(id contactId){
        system.debug('contactId ' +contactId );
        list<task> contactTask=new list<task>();
        list<Application__c> appList=[select id,Contact__c from Application__c where Contact__c=:contactId];
       
      //  Application__c appList=[select id,Contact__r.id,(select id,Subject,Description,Who.Name,ActivityDate From Tasks ) 
                             //  from  Application__c where Contact__r.id= :ContactId];
   
        list< Contact> cons=new list<Contact>();
        cons=[select id from contact where id=:appList[0].Contact__c];
       //  cons= [select id,(select id,subject,Description,Who.Name,ActivityDate From Tasks) from contact where id=:appList[0].Contact__c];
    list<Task> tsk=[select id,whoId from task where whoId=:cons];
        system.debug('Task' +tsk);
        return tsk;
    }
    
}

Componenet


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes"
                access="global" controller="ContactActivityHistory">
    
    <aura:attribute name="recordId" type="Id"/>
   
    <aura:attribute name="newTask" type="Task" default="{'sobjectType':'Task'}"/>
    <aura:attribute name="tasks" type="Task[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <aura:iteration items="{!v.tasks}" var="item">
        {!item.Subject}, {!item.ActivityDate}<br/>
    </aura:iteration>
    
</aura:component>

Js

({
    
    doInit : function(component, event, helper)
    {
        console.log('Test activity');
        var action = component.get("c.getContactTask");
        console.log('Test Activity @@@@');
        //  var action2=component.get('v.recordId');
        action.setParams({            
            "ContactId" : component.get('v.recordId')
        });
        
        console.log('Test my contact record activity ' +component.get('v.recordId'));
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS"){
                var records = response.getReturnValue();
                console.log('Server-> ' + JSON.stringify(records));
                
                var newItems=[];
                for (var i=0; i< records.length; i++)
                {
                    var record = records[i];
                    console.log('record-> ' + JSON.stringify(record));
                    
                    //   var Item = {title: record.Name, id: record.Id, status: "Unassigned"};
                    //  console.log('Item-> ' + JSON.stringify(Item));
                    
                    newItems.push(record);
                    console.log('newItems-> ' + JSON.stringify(newItems));
                }
                //component.set("v.tasks", newItems);
                
                
            } 
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                }
                
            }            
            
        });
        $A.enqueueAction(action);
        
        
    }  
})
Hi,

I have a requirement,have to show Custom object activity in contact related list.::
Contact and Custom__c,In this custom object I have to show activity of contacts.

Thanks.
Hi,

How to display activity for related object in contact object.
Is there any configuration way to show.,or how to do using custom component.
 
Hi,

Is there any way to show the activity of related object in contact object.

 
Hi,

Is there any way to create custom task component that should be displayed in related object  in salesforce.
Hi,

I have a requiremnet I have to show the activity related to object in contact object.

Thanks.
Hi,

I am trying to update records using data loader but not update,but when i do on single record its been updating.

I am written an trigger on task.
public class UpdateActivityHistoryCallCount {
    
    
    //To update the Count of Activity History in Lead object
    
    public static void countActivityHistoryOnLead(list<Task> newTaskList,list<Task> oldTaskList){
        system.debug('<<<<<test>>>>>');
        set<Id> LeadIds=new set<Id>();
        list<Lead> leadList=new list<Lead>();
        // Map<Id, String> error = new Map<Id, String>();
        
        if(trigger.isInsert || trigger.isUnDelete ){
            for(Task tsk:newTaskList){
                if(tsk.WhoId!=null){
                    if(string.valueOf(tsk.WhoId).startsWith('00Q'))
                        LeadIds.add(tsk.WhoId);
                    
                    
                }
                system.debug('Lead Ids' +LeadIds);
            }
        }
        if(trigger.isDelete || trigger.isUpdate){
            for(Task tk:oldTaskList){
                if(tk.WhoId!=null){
                    if(string.valueOf(tk.WhoId).startsWith('00Q'))
                        LeadIds.add(tk.whoId);
                    
                }
            }
            system.Debug('Test LeadIds' +LeadIds);
        }
        if(LeadIds.size()>0){
            for(Lead l:[select id,(select id,subject,Due_Date__c,CreatedDate
                                   from tasks where (subject='Call' and status='Completed'
                                                     and  Due_Date__c < Today) or (subject='Call' and status='Completed' and Due_Date__c =  null)  ) 
                        from lead where id in :LeadIds ])
                leadList.add(new lead(id=l.Id,Call_count__c=l.tasks.size()));
             update leadList;
            
            system.debug('Test');
        }
       
        
    }
    
    
Hi,

As I am able to update on single records but not working when its on bulk.

here is my code///
public class UpdateActivityHistoryCallCount {
    
    
    //To update the Count of Activity History in Lead object
    
    public static void countActivityHistoryOnLead(list<Task> newTaskList,list<Task> oldTaskList){
        set<Id> LeadIds=new set<Id>();
        list<Lead> leadList=new list<Lead>();
        Map<Id, String> error = new Map<Id, String>();
        
        if(trigger.isInsert || trigger.isUnDelete || trigger.isUpdate){
            for(Task tsk:newTaskList){
                if(string.valueOf(tsk.WhoId).startsWith('00Q'))
                    LeadIds.add(tsk.WhoId);
                
            }
        }
        if(trigger.isDelete || trigger.isUpdate){
            for(Task tk:oldTaskList){
                if(string.valueOf(tk.WhoId).startsWith('00Q'))
                    LeadIds.add(tk.whoId);
                
            }
        }
        if(LeadIds.size()>0){
            for(Lead l:[select id,(select id,subject,Due_Date__c,CreatedDate
                                   from tasks where (subject='Call' and status='Completed'
                                                     and  Due_Date__c < Today) or (subject='Call' and status='Completed' and Due_Date__c =  null)  ) 
                        from lead where id in :LeadIds limit 50000])
                leadList.add(new lead(id=l.Id,Call_count__c=l.tasks.size()));
            
            
        }
        Database.SaveResult[] results= database.update (leadList,false);
        system.debug('@@@@' +results);
        
    }
    
}

Thanks
Hi,

Is there any way,how to get the counts for task attached in lead object in past times.

Thanks.
Hi,

 I am getting error too many SOQL queries.

list<lead> myLeadList=[select id,name,Ad_key__c,Advertising_Key__c from lead where Ad_key__c =null];
for(lead l:myLeadList){
 list<Lead_Vendors__c> le=[select id,Ad_key__c from Lead_Vendors__c where Ad_key__c=:l.Advertising_Key__c];
    if(le!=null && le.size()>0){
    l.Ad_key__c=le[0].id;
    update l;    
    }
    
}
 
Hi,

I need to make a process,when there is 0 count record send email.

 

Hi,

How to captute user last login date in custom object .

Hi,

This is below my JSON,as I need the value of "Result",but i am getting null value on it.

Please have a loook:

 public static void testSynchMethod(){
       string strEmail='{\"Code\":201,\"Meassge\":\"Created\",\"Details\":\" Request: { email: bob@example.com first_name: Bob last_name: Smith }, Result: { id: 15361872, created_at: 2020-02-05T09:29:50.47Z, first_name: Bob, last_name: Smith, full_name: Bob Smith, company: null, email: bob@test.com, roles: [], avatar_url: null, bio: null, headline: null, affiliate_code: null, external_source: null, affiliate_commission: null, affiliate_commission_type: %, affiliate_payout_email: null, administered_course_ids: null, custom_profile_fields: [ { id: null, value: null, label: sso_id, custom_profile_field_definition_id: 16009 } ] } \"}';
           map<string,object> cObjMap=(map<string,object>) JSON.deserializeUntyped(strEmail);
       
        string objJSON=JSON.serialize(cObjMap.get('Details'));
        Map<String, Object> ResultParam = (Map<String, Object>)cObjMap.get('Result');
        system.debug('>>>>>>>>>>>>'+ResultParam);
        
        

JOSN---
{ "Code": 201, "Meassge": "Created", "Details": " Request: { email: bob@example.com first_name: Bob last_name: Smith }, Result: { id: 15361872, created_at: 2020-02-05T09:29:50.47Z, first_name: Bob, last_name: Smith, full_name: Bob Smith, company: null, email: bob@test.com, roles: [], avatar_url: null, bio: null, headline: null, affiliate_code: null, external_source: null, affiliate_commission: null, affiliate_commission_type: %, affiliate_payout_email: null, administered_course_ids: null, custom_profile_fields: [ { id: null, value: null, label: sso_id, custom_profile_field_definition_id: 16009 } ] } " }

Hello,


As per documentation by Five9Adaptor I followed in my org.

But not getting working properly.

Anybody have worked on five9-Salesforce SSO.


Thanks

Hi,

As I am unable to complete the code coverage in batch apex.
global class countContactRecordsBatch implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc) {
        string query='select id,Census_Date__c from hed__Term__c where Census_Date__c=LAST_N_DAYS:1';
        system.debug('query' +query) ;
        return Database.getQueryLocator(query); 
    }
    
    global void execute(Database.BatchableContext bc, List<hed__Term__c> scope){
        
        list<hed__Term__c> termList=[select id from hed__Term__c where Census_Date__c=LAST_N_DAYS:1];
        list<hed__Course_Offering__c> moduleOfferingList=[select hed__Term__r.id,(select hed__Contact__r.id,hed__Program_Enrollment__r.Program__r.id  from hed__Course_Enrollment__r) from hed__Course_Offering__c where hed__Term__r.id IN:termList];
        Map<string,set<string>> termProgramContacts=new Map<string,set<string>>();
        for(hed__Course_Offering__c co:moduleOfferingList) {
            system.debug('Term Id-'+co.hed__Term__r.id);   
            
            for(hed__Course_Enrollment__c ce:co.hed__Course_Enrollment__r){
                string mapKey = co.hed__Term__r.id+'-'+ce.hed__Program_Enrollment__r.Program__r.id;
                if(ce.hed__Program_Enrollment__r.Program__r.id!=null){
                    if(termProgramContacts.containsKey(mapKey)){
                        set<string> existingValue = termProgramContacts.get(mapKey);
                        existingValue.add(ce.hed__Contact__r.id);
                        termProgramContacts.put(mapKey, existingValue);
                    }                       
                    else{
                        set<string> newValue = new set<string>();   
                        newValue.add(ce.hed__Contact__r.id);
                        termProgramContacts.put(mapKey,newValue);
                    }
                }
            }
        }
            
            system.debug('Program Contact- '+termProgramContacts);
            list<hed__Term__c> termProgramList=new list<hed__Term__c>();
            list <Program_Session__c> programSessionList = new list <Program_Session__c>();
            termProgramList=[select id,(select id,Program__r.id from Program_Sessions__r) from hed__Term__c where id IN:termList];
            Map<string,integer> updateCount = new Map<string,integer>();
            for(hed__Term__c termProgram:termProgramList){
                for(Program_Session__c ps:termProgram.Program_Sessions__r){
                    string tpKey = termProgram.id+'-'+ps.Program__r.id;
                    if(termProgramContacts.containsKey(tpKey)){
                        integer contactCount = termProgramContacts.get(tpKey).size();
                        integer existingCount = 0;
                        if(updateCount.containsKey(ps.id)){
                            existingCount = updateCount.get(ps.id);                         
                        }
                        updateCount.put(ps.id,contactCount+existingCount);//progran term id and count
                        system.debug('updateCount'+updateCount.values().size());
                    }
                    ps.Total_enrolments_actual__c=updateCount.get(ps.Id);
                    programSessionList.add(ps);
                    system.debug('Total_enrolments_actual__c' +ps.Total_enrolments_actual__c);                    
                    system.debug('termProgramList ' +termProgramList);            
                }
            }
            if(programSessionList!=null && !programSessionList.isEmpty()){
                update programSessionList;
                
                
            }
        
    }
            global void finish(Database.BatchableContext BC){
                
            }

       
    //code end
    
   
}
===
Test class
=====

@isTest
public class countContactRecordsBatchTest {
    
    static testMethod void contactRecords(){
        
        list<Program_Session__c> psList=new list<Program_Session__c>();
        list<Account> acc=new list<Account>();
        list<hed__Term__c> termList=new list<hed__Term__c>();//term 
        list<Program__c> programList=new list<Program__c>();
        list<hed__Course_Offering__c> mcList=new list<hed__Course_Offering__c>();
        list<hed__Course__c> courseList=new list<hed__Course__c>();
        list<hed__Program_Enrollment__c> prEnrollmentList=new list<hed__Program_Enrollment__c>();
        list<Contact> consList=new list<contact>();
        
        
        Account a=new account();
        a.Name='Test Account';
        acc.add(a);
        
        insert acc;
        
        hed__Term__c te=new hed__Term__c();
        te.Name='test term';
        te.hed__Account__c=acc[0].id;
        te.Census_Date__c=date.today();
        termList.add(te);
        insert termList;//Term
        
        Program__c pc=new Program__c();
        pc.Name='test program ';
        programList.add(pc);//Program ..
        
        
        //insert module offering
        hed__Course_Offering__c mc=new hed__Course_Offering__c();
        hed__Course__c cou=new hed__Course__c();
        cou.name='test course';
        cou.hed__Account__c=acc[0].Id;
        courseList.add(cou);
        insert courseList;
        
        mc.Name='Test Module Offering';
        mc.hed__Course__c=courseList[0].id;
        mc.hed__Term__c=termList[0].id;
        mcList.add(mc);
        
        
        //Insert contact
        contact con=new contact();
        con.lastName='test contact Name';
        consList.add(con);    
        
        
        //program Enrollment
        hed__Program_Enrollment__c pe=new hed__Program_Enrollment__c();
        pe.Program__c=programList[0].id;
        pe.hed__Contact__c=consList[0].id;
        prEnrollmentList.add(pe);
        
        
        Program_Session__c ps=new Program_Session__c();
        ps.Term__c=termList[0].id;
        //     ps.Program__c=programList[0].id;
        ps.Program__c=programList[0].id;
        //ps.Total_enrolments_actual__c=1;
        psList.add(ps);
        database.insert (psList,false);
        
        list<Program_Session__c> prs=[select id ,Term__r.id,Program__r.id,Total_enrolments_actual__c from Program_Session__c];
        for(Program_Session__c pccc:prs){
            pccc.Total_enrolments_actual__c=10;
        }
        
        test.startTest();
        
        database.SaveResult []sr=database.update(prs,false);
        countContactRecordsBatch obj=new countContactRecordsBatch();
        database.executeBatch(obj);
        test.stopTest();
    }
    
}

As I am getting 44% code coverage on it.
Any suggestions.

Thanks
Hi,

I am creating a test class for updating a field ,but there is one issue am getting an error System.NullPointerException: Attempt to de-reference a null object

@isTest
public class countContactRecordsBatchTest {
    
    static testMethod void contactRecords(){
        list<Program_Session__c> ps=new list<Program_Session__c>();
        
                    Account a=new account();
                    a.Name='Test Account';
                    insert a;
            hed__Term__c  t=new hed__Term__c();//insert Program term
            t.Name='Test Term';

            t.hed__Account__r.id=a.Id;
            t.Census_Date__c=date.today();
            insert t;
            
            Program__c pr=new Program__c();//insert Program
            pr.Name='Test Program ';
            insert pr;
            
            Program_Session__c psR=new Program_Session__c();
            psR.Program__r.name=pr.Name;
            psR.Term__r.name=t.Name;
            
            ps.add(psR);
            
            
        }
        
        test.startTest();
        Database.SaveResult []str = Database.insert(ps,false);
        countContactRecordsBatch obj=new countContactRecordsBatch();
        database.executeBatch(obj);
        
    }
}
Hi All,

I want to know the basic resons for below point:

1.can we call future method into batch apex,if not why??
2.can we call futute method into anothrt future method??
Hi,

I have written an schedule class,in which when I run in production,it threw an error caused by: System.LimitException: Too many query rows: 50001

 line 25, column 1

 public void execute(SchedulableContext sc){
        
        list<lead> myFive9LeadList=[ select id,name,Originating_System__c,createdDate,Call_Center_Disposition_Date__c,Call_Center_Disposition_Details__c from lead where Originating_System__c='Five9' AND createdDate >:X15MinutesAgo];
        list<lead> mySparkroomLeadList=[ select id,name,Originating_System__c,createdDate from lead where Originating_System__c='Sparkroom' AND createdDate >:X15MinutesAgo];

//Line 25
        list<lead> myLeadListDispositions=[ select id,name,Originating_System__c,createdDate from lead where Call_Center_Disposition_Details__c='Transfer' AND Call_Center_Disposition_Date__c >:X15MinutesAgo];
        
        
        //For No Lead from Five9
        if(myFive9LeadList.size()==0 ){
            system.debug('Five9 List Size'+ myFive9LeadList.size());
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(toAddresses );
            mail.setCcAddresses(ccAddresses);
            mail.setSubject('Notification:: No Lead from Five9');
            String messageBody = '<html><body>Hi, &nbsp;&nbsp;&nbsp;</body> <br/> Last 15 minutes no lead generated from Five9.<br/>Please look into Five9 lead process and make sure that it is working fine.<br/><br/>Thanks </html>


Thanks..





 
Hi,

I am trting to populate the contacts task in my application object,but I am trying to passng the contactId ,confuse over it how to do.
Kindly suggest!!!!

Here is my code.

 public static list<Task> getContactTask(string contactId){
  list<task> contactTask=new list<task>();
        list<contact> consList=[select id,name,(select id from applications__r) from contact where id=:contactId];
       list<Task> tsk=[select id,whoId from task where whoId=:consList[0].id];
        system.debug('Task' +tsk);
        return tsk;
}
}

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes"
                access="global" controller="ContactActivityHistory">
    
    <aura:attribute name="recordId" type="Id"/>
   
    <aura:attribute name="newTask" type="Task" default="{'sobjectType':'Task'}"/>
    <aura:attribute name="tasks" type="Task[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <aura:iteration items="{!v.tasks}" var="item">
        {!item.Subject}, {!item.ActivityDate}<br/>
    </aura:iteration>
    
</aura:component>


Js.
({
    
    doInit : function(component, event, helper)
    {
        console.log('Test activity');
        var action = component.get("c.getContactTask");
        console.log('Test Activity @@@@');
        // var action=component.get('v.recordId');
        console.log(component.get("v.recordId")); 
        action.setParams({            
            ContactId : component.get('v.recordId')
        });
        
        console.log('Test my contact record activity ' +component.get('v.recordId'));
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS"){
               // var records = response.getReturnValue();
               // console.log('Server-> ' + JSON.stringify(records));
                alert("From server: " + response.getReturnValue());
                var newItems=[];
                for (var i=0; i< records.length; i++)
                {
                    var record = records[i];
                    console.log('record-> ' + JSON.stringify(record));
                    
                    //   var Item = {title: record.Name, id: record.Id, status: "Unassigned"};
                    //  console.log('Item-> ' + JSON.stringify(Item));
                    
                    newItems.push(record);
                    console.log('newItems-> ' + JSON.stringify(newItems));
                }
                component.set("v.tasks", newItems);
                
                
            } 
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                }
                
            }            
            
        });
        $A.enqueueAction(action);
        
        
    }  
})


Thanks
 
Hi,

I have created a component to show the contact activity in my object.

public class ContactActivityHistory {
    
    @auraEnabled
    
    public static list<Task> getContactTask(id contactId){
        system.debug('contactId ' +contactId );
        list<task> contactTask=new list<task>();
        list<Application__c> appList=[select id,Contact__c from Application__c where Contact__c=:contactId];
       
      //  Application__c appList=[select id,Contact__r.id,(select id,Subject,Description,Who.Name,ActivityDate From Tasks ) 
                             //  from  Application__c where Contact__r.id= :ContactId];
   
        list< Contact> cons=new list<Contact>();
        cons=[select id from contact where id=:appList[0].Contact__c];
       //  cons= [select id,(select id,subject,Description,Who.Name,ActivityDate From Tasks) from contact where id=:appList[0].Contact__c];
    list<Task> tsk=[select id,whoId from task where whoId=:cons];
        system.debug('Task' +tsk);
        return tsk;
    }
    
}

Componenet


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes"
                access="global" controller="ContactActivityHistory">
    
    <aura:attribute name="recordId" type="Id"/>
   
    <aura:attribute name="newTask" type="Task" default="{'sobjectType':'Task'}"/>
    <aura:attribute name="tasks" type="Task[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <aura:iteration items="{!v.tasks}" var="item">
        {!item.Subject}, {!item.ActivityDate}<br/>
    </aura:iteration>
    
</aura:component>

Js

({
    
    doInit : function(component, event, helper)
    {
        console.log('Test activity');
        var action = component.get("c.getContactTask");
        console.log('Test Activity @@@@');
        //  var action2=component.get('v.recordId');
        action.setParams({            
            "ContactId" : component.get('v.recordId')
        });
        
        console.log('Test my contact record activity ' +component.get('v.recordId'));
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS"){
                var records = response.getReturnValue();
                console.log('Server-> ' + JSON.stringify(records));
                
                var newItems=[];
                for (var i=0; i< records.length; i++)
                {
                    var record = records[i];
                    console.log('record-> ' + JSON.stringify(record));
                    
                    //   var Item = {title: record.Name, id: record.Id, status: "Unassigned"};
                    //  console.log('Item-> ' + JSON.stringify(Item));
                    
                    newItems.push(record);
                    console.log('newItems-> ' + JSON.stringify(newItems));
                }
                //component.set("v.tasks", newItems);
                
                
            } 
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                }
                
            }            
            
        });
        $A.enqueueAction(action);
        
        
    }  
})
Hi,

I have a requirement,have to show Custom object activity in contact related list.::
Contact and Custom__c,In this custom object I have to show activity of contacts.

Thanks.
Hi,

How to display activity for related object in contact object.
Is there any configuration way to show.,or how to do using custom component.
 
Hi,

Is there any way to create custom task component that should be displayed in related object  in salesforce.
Hi,

I have a requiremnet I have to show the activity related to object in contact object.

Thanks.
Hi,

I am trying to update records using data loader but not update,but when i do on single record its been updating.

I am written an trigger on task.
public class UpdateActivityHistoryCallCount {
    
    
    //To update the Count of Activity History in Lead object
    
    public static void countActivityHistoryOnLead(list<Task> newTaskList,list<Task> oldTaskList){
        system.debug('<<<<<test>>>>>');
        set<Id> LeadIds=new set<Id>();
        list<Lead> leadList=new list<Lead>();
        // Map<Id, String> error = new Map<Id, String>();
        
        if(trigger.isInsert || trigger.isUnDelete ){
            for(Task tsk:newTaskList){
                if(tsk.WhoId!=null){
                    if(string.valueOf(tsk.WhoId).startsWith('00Q'))
                        LeadIds.add(tsk.WhoId);
                    
                    
                }
                system.debug('Lead Ids' +LeadIds);
            }
        }
        if(trigger.isDelete || trigger.isUpdate){
            for(Task tk:oldTaskList){
                if(tk.WhoId!=null){
                    if(string.valueOf(tk.WhoId).startsWith('00Q'))
                        LeadIds.add(tk.whoId);
                    
                }
            }
            system.Debug('Test LeadIds' +LeadIds);
        }
        if(LeadIds.size()>0){
            for(Lead l:[select id,(select id,subject,Due_Date__c,CreatedDate
                                   from tasks where (subject='Call' and status='Completed'
                                                     and  Due_Date__c < Today) or (subject='Call' and status='Completed' and Due_Date__c =  null)  ) 
                        from lead where id in :LeadIds ])
                leadList.add(new lead(id=l.Id,Call_count__c=l.tasks.size()));
             update leadList;
            
            system.debug('Test');
        }
       
        
    }
    
    
Hi,

 I am getting error too many SOQL queries.

list<lead> myLeadList=[select id,name,Ad_key__c,Advertising_Key__c from lead where Ad_key__c =null];
for(lead l:myLeadList){
 list<Lead_Vendors__c> le=[select id,Ad_key__c from Lead_Vendors__c where Ad_key__c=:l.Advertising_Key__c];
    if(le!=null && le.size()>0){
    l.Ad_key__c=le[0].id;
    update l;    
    }
    
}
 
Hi All,
     I have a simple apex method used in ligthing lookup to search name and phone fields.
apex method:
   @AuraEnabled  
     public static List<sObject> getRecordList(String objName,String searchText,String fieldInSearch,String phone){
        string searchKey = '%' + searchText + '%';
        string Query =' select ' +fieldInSearch+ ',' +phone;
        Query+=' from '+objName;
        Query+=' where '+fieldInSearch+ ' like  \''+searchKey+'\' LIMIT 5';
            system.debug('Query == >> '+Query);
        List<sObject> sObjectList = Database.query(Query);
        system.debug(' #### sobjectList ' + sObjectList);
        return sObjectList;
    }
Test class :
 @isTest static void searchAcc(){
        String searchText = 'test';
        string field = 'name';
        string obj = 'Account';
        string phone='12345';
        List<account> a = apexHandler.getRecordList(obj,searchText,field,phone);
        system.debug('Account'+a);
        system.assertEquals(1, a.size());
    }
when i run the test the method gets failed and showing error System.QueryException: unexpected token: '12345' and at line no Database.query(Query) from apex method.
I gone through different solutions but unable to resolve, could any one help me with this to resolve and run test method succesfully.
Hi,

I need to make a process,when there is 0 count record send email.

 

Hi,

How to captute user last login date in custom object .

Hi,

I am creating a test class for updating a field ,but there is one issue am getting an error System.NullPointerException: Attempt to de-reference a null object

@isTest
public class countContactRecordsBatchTest {
    
    static testMethod void contactRecords(){
        list<Program_Session__c> ps=new list<Program_Session__c>();
        
                    Account a=new account();
                    a.Name='Test Account';
                    insert a;
            hed__Term__c  t=new hed__Term__c();//insert Program term
            t.Name='Test Term';

            t.hed__Account__r.id=a.Id;
            t.Census_Date__c=date.today();
            insert t;
            
            Program__c pr=new Program__c();//insert Program
            pr.Name='Test Program ';
            insert pr;
            
            Program_Session__c psR=new Program_Session__c();
            psR.Program__r.name=pr.Name;
            psR.Term__r.name=t.Name;
            
            ps.add(psR);
            
            
        }
        
        test.startTest();
        Database.SaveResult []str = Database.insert(ps,false);
        countContactRecordsBatch obj=new countContactRecordsBatch();
        database.executeBatch(obj);
        
    }
}
Hi,

I am stuck in map.
Map-1 contactsAndEnrollmentMap  
     which contain           contactsAndEnrollmentMap.put(mc.hed__Contact__r.id,enRollmentId);

Map --2 programEnrollmentAndProgramCodeMap
which contain
 programEnrollmentAndProgramCodeMap.put(pe.id,programCode);

Now I want to create new map which contain programCode(Key ) and hed__Contact__r(Value);


Thanks
Hi,

As I have two maps 
Map 1---Program code and ContactId
Map 2---Program Code and Program term.


Now how to get the count of uniques program code from these two map.

Any idea.
Hi,
I am getting error...below code:

     map<string,set<id>> contactIdAndProgramCode=new map<string,set<id>>();
        for(string c:programEnrollmentAndProgramMap.values()){
            for(id i:termModuleofferingModuleConnectionMap.keySet()){
            contactIdAndProgramCode.put(c,termModuleofferingModuleConnectionMap.get(i));// Program code and ContactIds
             }
        }
        
    Error---Invalid loop variable type expected Set<String> was String
Hi I have some 9 sobjects data retrieved via SOQL. Now I want to add all this List's to a Generic List<sobejct> type to perform single DML operation

Can't this be done with out using For-loops ?
I tried addALL method od list