# Undefined method for nil:NILClass

Troubleshoot undefined method error under 3 min

You may encounter the following error when you use a formula on a datapill that doesn't contain a value:

Undefined method for nil:NilClass

This error indicates that the datapill didn't contain a value at runtime.

Example of Undefined method for nil:NILClass Example of Undefined method for nil:NILClass

# Why it happens

This error occurs when the value of the datapill is null at runtime. The following scenarios can cause this error:

  • A Get action returns records with missing fields.
  • A Search action returns no results.
  • A SQL query returns 0 rows.

For example, your datapill doesn't contain any value when step 2 has missing fields, which means that step 3 (Update lead in Marketo) applies a formula to an empty datapill.

Example of Undefined method for nil:NILClass Example of Undefined method for nil:NILClass

Since the capitalize formula doesn't apply to a datapill with no value, the job fails with the following error:

Error calculating input for field 'company':
Formula received a nil value:
undefined method `capitalize' for nil:NilClass

# How to troubleshoot

Use the & safe navigation operator in your formula to prevent errors when the datapill is null. For example:

[Datapill]&.capitalize

The operator checks if the datapill has a valid value:

  • The operator applies the formula if the datapill contains a value.
  • The operator skips the formula and returns null if the datapill is null.

This ensures the recipe continues without failure.

Example of using the safe navigation operator Example of using the safe navigation operator with the .capitalize formula


Last updated: 9/23/2025, 8:10:28 PM