Skip to main content

Missed Opportunity: defaultValue and placeholderText Modifiers

David Martin avatar
Written by David Martin
Updated over a week ago

Overview

This rule identifies invocable variables that could benefit from using the defaultValue and placeholderText modifiers within the @InvocableVariable annotation. These optional modifiers enhance how input parameters appear in Flow Builder, giving admins clearer guidance and improving the overall usability of custom actions.


Code Reviews classifies this as a Warning, as failing to use these modifiers does not break functionality. However, adding them can significantly improve clarity, reduce configuration errors, and streamline the flow building experience.
​

Why This Matters

When an invocable method is exposed to Flow Builder, Salesforce displays each input parameter in the Action configuration panel. If no placeholder text or default value is provided:

  • Flow admins receive no contextual hint about how the value should be used

  • Configuration may take longer, especially for complex or less obvious inputs

  • Inconsistent naming or unclear requirements can lead to misconfigured flows

  • Best practice user experience improvements are missed

Using the defaultValue and placeholderText modifiers helps surface guidance directly where admins need it improving adoption, accuracy, and maintainability.


What Triggers This Rule

This rule flags occurrences of the @InvocableVariable annotation that do not specify:

  • defaultValue

  • placeholderText

It is not an error only a reminder that these modifiers are available and may improve the flow configuration experience. The rule fires for any invocable variable where either modifier could be applied to provide clearer intent or better usability.
​

Recommended Approach

To take advantage of these enhancements, update your invocable variables by adding the appropriate modifiers:

Provide a helpful placeholderText

Explain what type of value should be entered or how it will be used.

@InvocableVariable(
label='Record ID',
description='The ID of the record to process',
placeholderText='Enter a valid Salesforce record ID'
)
public String recordId;

Add a sensible defaultValue where appropriate

Use this to reduce repetitive input for frequently used values.

@InvocableVariable(
label='Retry Count',
defaultValue='3'
)
public Integer retries;
When to use these modifiers
  • Anytime an input parameter might be unclear to a flow admin

  • When defaulting a value prevents configuration errors

  • When providing contextual hints improves discoverability or usability

Summary

The defaultValue and placeholderText modifiers in the @InvocableVariable annotation enhance how custom invocable actions appear in Flow Builder. Although optional, they offer meaningful improvements to user experience and reduce configuration errors. Code reviews flags their absence as a Missed Opportunity, encouraging developers to add clarity, consistency, and helpful defaults when exposing parameters to Flow Builder.

Scope

  • Apex Classes

Related resources


​

Did this answer your question?