• rroberts
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

I want to pull a list of Leads from a SOQL query, where the Leads meet some requirements, and are also found in another list from a previous query.

 

A dumbed down version of what I've got:

 

List<AggregateResult> numTasks = [SELECT WhoId
    FROM Task
    WHERE
        status='Completed' AND
        isClosed = true AND
        ActivityDate = LAST_N_DAYS:35
    GROUP BY WhoId
    HAVING count(id) >= :TASKS_MAX];

List<Lead> openLeads = [Select id, ownerId
    FROM Lead
    WHERE
        OwnerId = 'Enter a queue ID here' AND
        Days_Since_Modified__c <= :NUM_OF_DAYS_TO_WATCH AND
        Id IN :numTasks];

 I get:"Error: Compile Error: Invalid bind expression type of SOBJECT:AggregateResult for Id field of SObject Lead at line 63 column 25"

 

I understand it's a type issue, but I find it funny I can go from a Lead List to an Aggregate Result, but not vice versa.

 

How do I do this correctly?  I can't seem to find anything about AggregateResult Lists in the developer's guide that addresses this.

 

Hi all,

 

I'm a long time developer, but new to Apex.  I've written an Apex scheduler class that counts LeadHistory fields to determine what to do with the Lead.  I'm now in the testing stage, but the more I research, the more I find that test cases are impossible (?!) for History tables.

 

My sandbox has no leads, etc in it, so I add the leads in the test cases and immediately change a value, hoping that will create LeadHistory entries, but it doesn't seem to:

 

insert new Lead(Company = 'Lead Company', FirstName = 'firstname', LastName = 'lastname');
Lead l = [select id from Lead Limit 1];
l.OwnerId = '005a0000008V0qDAAS';
update l;

 The assert comes back with LeadHistory being empty...

 

Is it really impossible to write tests for my code?  How am I supposed to test and deploy the code then?

 

Edit: I got the info that it's impossible from several forum posts, such as:
http://boards.developerforce.com/t5/Apex-Code-Development/Code-coverage-for-History-class/m-p/323429/thread-id/57307

I want to pull a list of Leads from a SOQL query, where the Leads meet some requirements, and are also found in another list from a previous query.

 

A dumbed down version of what I've got:

 

List<AggregateResult> numTasks = [SELECT WhoId
    FROM Task
    WHERE
        status='Completed' AND
        isClosed = true AND
        ActivityDate = LAST_N_DAYS:35
    GROUP BY WhoId
    HAVING count(id) >= :TASKS_MAX];

List<Lead> openLeads = [Select id, ownerId
    FROM Lead
    WHERE
        OwnerId = 'Enter a queue ID here' AND
        Days_Since_Modified__c <= :NUM_OF_DAYS_TO_WATCH AND
        Id IN :numTasks];

 I get:"Error: Compile Error: Invalid bind expression type of SOBJECT:AggregateResult for Id field of SObject Lead at line 63 column 25"

 

I understand it's a type issue, but I find it funny I can go from a Lead List to an Aggregate Result, but not vice versa.

 

How do I do this correctly?  I can't seem to find anything about AggregateResult Lists in the developer's guide that addresses this.

 

Hi all,

 

I'm a long time developer, but new to Apex.  I've written an Apex scheduler class that counts LeadHistory fields to determine what to do with the Lead.  I'm now in the testing stage, but the more I research, the more I find that test cases are impossible (?!) for History tables.

 

My sandbox has no leads, etc in it, so I add the leads in the test cases and immediately change a value, hoping that will create LeadHistory entries, but it doesn't seem to:

 

insert new Lead(Company = 'Lead Company', FirstName = 'firstname', LastName = 'lastname');
Lead l = [select id from Lead Limit 1];
l.OwnerId = '005a0000008V0qDAAS';
update l;

 The assert comes back with LeadHistory being empty...

 

Is it really impossible to write tests for my code?  How am I supposed to test and deploy the code then?

 

Edit: I got the info that it's impossible from several forum posts, such as:
http://boards.developerforce.com/t5/Apex-Code-Development/Code-coverage-for-History-class/m-p/323429/thread-id/57307