function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
o2bo2b 

Getting Java Exception in Apex Scheduler

We have a workflow which kicks-off based on a checkbox update in a custom object and sends email alert with Visualforce Email Template. Visualforce Email Template must have <apex:image>.

Then We developed an Apex scheduler which can update the checkbox so that the email alert goes every hour. While executing the Apex code it failed at the update of the checkbox with error -
'EXCEPTION_THROWN|[12]|System.DmlException: Update failed. First exception on row 0 with id a0A90000000AsaXEAS; first error: UNKNOWN_EXCEPTION, java.lang.NullPointerException: Argument Error: Parameter value is null:[]'

We can update that checkbox manually and send that email alert without any problem OR if we remove <apex:image> tag then it works fine.

 

Any idea on this issue???

sfdcfoxsfdcfox

Usually a java.lang.* error suggests that there's a problem with the platform, and not anything specifically you're doing wrong. I would suggest filing a case with Developer Support. That being said, it would help if you could provide some code that would allow the community to replicate the issue at hand. You don't necessarily need to provide your full code, just enough that a developer here could replicate the issue.

o2bo2b

I have raised the case to Salesforce already, so far they have not resolved yet. Code part is very straight -

 

1. Create a custom object with a checkbox

2. Create a workflow which triggers on the checkbox update

3. Add a Visualforce email template which must have <apex:image>, which is intended to be emailed when the workflow triggers

4. Then create Apex schedule class to update that checkbox periodically, you can even try to update one record only

tharristharris

o2b,

 

I believe this is a known bug. There isn't a fix yet but we are working on it. Can you send me your case number [thomas.harris at salesforce dot com] so I can get in touch with support?

 

Thanks,

-Thomas

_Prasu__Prasu_

Yes, I too came across this bug many times. This mostly happens when you Schduler tries to send an email through a Workflow. I raised an Case with Support, but they said that  values binded in the email template are not getting binded and its getting that exception. Same workflow and code works fine if its not executed as a schduler.

 

For the workaround I converted email sending workflows to timer workflow and they are working fine uptill now.