Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mass Edit Volunteer Hours Page Updates All Volunteer Hours Records Retrieved #507

Open
jesslopez-sf opened this issue Mar 2, 2021 · 1 comment

Comments

@jesslopez-sf
Copy link

Older and super similar Github Issue referencing the CPU consumption and Collection Error: #26

Issue:

Customers may run into CPU Timeout errors or Collection Size Errors if Too Many Volunteer Job records are pulled into the Mass Edit Volunteer Hours Page or if customers have other automations running on top of V4S which run on save.

Apex CPU time limit exceeded

Error is in expression '{!SaveVolunteerHours}' in component <apex:commandButton> in page
gw_volunteers:volunteersbulkenterhours: Class.npsp.TDTM_Runnable.DmlWrapper.<init>: line 144, column 1
Class.npsp.TDTM_TriggerHandler.run: line 79, column 1
Class.npsp.TDTM_Config_API.run: line 92, column 1
Trigger.npsp.TDTM_Campaign: line 33, column 1

Root Cause

When the SaveVolunteerHours() method is called within the VOL_CTRL_VolunteersBulkEnterHours class, we update all Volunteer Job records that were passed into the Visualforce page. There’s a comment within the code indicating this was intentional , though we attempted to implement logic at one point to determine which records were updated:
https://github.com/SalesforceFoundation/Volunteers-for-Salesforce/blob/master/src/classes/VOL_CTRL_VolunteersBulkEnterHours.cls#L301-L310

Steps to Repeat:

For Dev/QE: feel free to use the Snowfakery file attached to the Work Item. It will create a Campaign, Volunteer Job, 995 Contacts, and 995 Volunteer Job records in your org. I’m using 995 here since 5 empty rows are loaded on the page. If more than 1000 rows are created on the page, we run into a Visualforce limit for collection size.

Otherwise:

  1. Create a Campaign where the Status is Active.
  2. Create a Volunteer Job record
  3. Create 995 Contacts.
  4. Create 995 Volunteer Hour records for those Contacts and relate them to the Volunteer Job.
  5. Go to the Volunteer Job detail page and click the “Mass Edit Volunteer Hours” button on the Volunteer Hours Related List.
  6. Change the Status for just 1 row and click save.
  7. The controller will attempt to update all 995 records and will hit a CPU Timeout error.

Workarounds:

  1. Use filters to reduce the amount of Volunteer Jobs displayed on the page.
  2. Follow Best Practices around automation, especially around Volunteer Hours, Volunteer Job, and Contact objects. (i.e. 1 automation type per object / use before update flows instead of after update flows when relevant / etc.)
@jesslopez-sf
Copy link
Author

W-8957457

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant