Volunteers-for-Salesforce icon indicating copy to clipboard operation
Volunteers-for-Salesforce copied to clipboard

PersonalSiteReportHours Page: Some Jobs May Not Be Displayed if More than 999 Active Jobs

Open jesslopez-sf opened this issue 4 years ago • 2 comments

When customer orgs have more than 999 active Volunteer Jobs, it is possible that some volunteers' Jobs will not display on the Report Hours Personal Site Page.

This is because we cap Volunteer Jobs at 999 in this SOQL query:


SELECT Name, Id, 
    (SELECT Id, GW_Volunteers__Contact__c 
    FROM GW_Volunteers__Volunteer_Hours__r 
    WHERE GW_Volunteers__Contact__c = '003xxxxxxxxxxxx' LIMIT 1) 
FROM GW_Volunteers__Volunteer_Job__c 
WHERE (GW_Volunteers__Campaign__r.IsActive = TRUE 
    AND GW_Volunteers__Inactive__c = FALSE) 
ORDER BY name ASC NULLS FIRST
LIMIT 999

It only returns 999 Volunteer Jobs and then only adds those Volunteer Jobs where the Contact is the Id of the Contact passed in to the drop-down menu. I ran the query in the Dev Console’s Query Editor and confirmed that only 5 of the jobs returned were associated with the Contact in the customer org. When I changed the limit to 20000, on the other hand, more Jobs associated with that Contact were returned.

This is happening in VOL_CTRL_VolunteersReportHours.cls, lines 171-178. We then add the matching jobs for that Contact in lines 185-193.

Steps to Repeat in Scratch Org:

  • Create Contact (First Name = ‘Test’; Last Name = ‘Test’; Email = YOUR_EMAIL_ADDRESS);
  • Create 2000 Volunteer Campaigns in Dev Console → Execute Anonymous:
 // I ran this 8 times because the Trigger that creates Campaign Statuses was eating up DML rows.
    
    List<Campaign> volCampaigns = new List<Campaign>();
    for(Integer x = 0; x < 2000; x++)
    {
        volCampaigns.add(new Campaign(
            Name = 'Campaign ' + x,
            IsActive = true
        ));
    }
    insert volCampaigns;
  • Create Volunteer Jobs in Execute Anonymous
List<Campaign> campList = [SELECT Id FROM Campaign];
    List<Volunteer_Job__c> jobsList = new List<Volunteer_Job__c>();
    
    for(Integer x = 0; x < campList.size(); x++)
    {
        jobsList.add(new Volunteer_Job__c(
            Name = 'Vol Job ' + x,
            Campaign__c = campList[x].Id,
            Display_on_Website__c = true
        ));
    }
    
    insert jobsList;
  • Add Volunteer Hours for a handful of jobs and relate to the Contact, for example all Contacts where the Campaign Name is Campaign 249.

    • Status = Prospect
    • Start Date = past date
  • Go to Personal Site page and click Report Hours tab.

  • Expected Behavior: you see all of that Volunteer’s relevant Jobs in the Volunteer Job list. Actual: you may not see all of them depending on whether or not the job was cut off from the query results.

jesslopez-sf avatar Mar 09 '20 14:03 jesslopez-sf

**lurch: add

jesslopez-sf avatar Mar 09 '20 14:03 jesslopez-sf

Tracking W-040031

LurchTheButler avatar Mar 09 '20 14:03 LurchTheButler