Improved Data Validation and Conversion for Apex Method Parameters

We’ve improved the validation for data passed from JavaScript to an Apex method. This improvement makes it easier to identify any errors in your code. We’ve also improved how we automatically convert data passed from JavaScript into Apex data types.

Where: This change applies to orgs with Lightning components in Lightning Experience, Salesforce Classic, and all versions of the Salesforce app.

Why: In previous releases, data passed from a JavaScript controller to some Apex types wasn’t deserialized correctly. This inconsistent behavior led to hard-to-diagnose bugs and cumbersome workarounds in Apex code.

How: We improved conversion of data for these Apex types:

  • Integer
  • Long
  • Double
  • Date
  • Time
  • List
  • SObject
  • Object

If you pass data that doesn’t conform to the type expected by an Apex method parameter, you get a detailed error message instead of a generic error message. The error message looks like:

Value provided is invalid for action parameter apexParamName of type 'apexDataType'