• 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 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