---
schema_version: "1"
id: 4e471b8563949d55f78f05219d3e59c1f6be3e9bd40904bb14864b47831bdf36
title: ActionResult.Builder Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_Messaging_ActionResult_Builder.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Messaging_ActionResult_Builder.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2fe805f0988cea2bf63880f3e26695fc7a30a77e1b03be41ad651d509fd7c32e
description: Contains methods to build and validate an instance of the Messaging.ActionResult class.Validates and returns the action result instance created by using the ActionResult.Builder methods.Sets the error message associated with the action error.Sets the success or error message associated with the execution of the action.Sets a Boolean that informs the user whether the execution of the action was successful (true) or not (false).
---
# ActionResult.Builder Class

Contains methods to build and validate an instance of the Messaging.ActionResult class.

## Namespace

[Messaging](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Messaging.htm "The Messaging namespace provides classes and methods for Salesforce notifications and email functionality.")

## Usage

See the example for the [NotificationActionHandler Interface](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Messaging_NotificationActionHandler.htm#apex_interface_Messaging_NotificationActionHandler "Implement this interface to execute an action on a custom notification.").

- **[ActionResult.Builder Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Messaging_ActionResult_Builder.htm#apex_Messaging_ActionResult_Builder_methods)**

## ActionResult.Builder Methods

The following are methods for ActionResult.Builder.

- **[build()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Messaging_ActionResult_Builder.htm#apex_Messaging_ActionResult_Builder_build)**  
    Validates and returns the action result instance created by using the ActionResult.Builder methods.
- **[withErrorCode(errorCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Messaging_ActionResult_Builder.htm#apex_Messaging_ActionResult_Builder_withErrorCode)**  
    Sets the error message associated with the action error.
- **[withMessage(message)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Messaging_ActionResult_Builder.htm#apex_Messaging_ActionResult_Builder_withMessage)**  
    Sets the success or error message associated with the execution of the action.
- **[withSuccess(success)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Messaging_ActionResult_Builder.htm#apex_Messaging_ActionResult_Builder_withSuccess)**  
    Sets a Boolean that informs the user whether the execution of the action was successful (true) or not (false).

### build()

Validates and returns the action result instance created by using the ActionResult.Builder methods.

#### Signature

public Messaging.ActionResult build()

#### Return Value

Type: [Messaging.ActionResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Messaging_ActionResult.htm#apex_class_Messaging_ActionResult "Contains information about the execution of an actionable notification.")

### withErrorCode(errorCode)

Sets the error message associated with the action error.

#### Signature

public Messaging.ActionResult.Builder withErrorCode(Messaging.ActionError errorCode)

#### Parameters

- **errorCode**:
    
    Type: [Messaging.ActionError](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_Messaging_ActionError.htm "Specifies the error that occurred during the execution of an actionable notification.")
    
    The error message.

#### Return Value

Type: [Messaging.ActionResult.Builder](#apex_class_Messaging_ActionResult_Builder "Contains methods to build and validate an instance of the Messaging.ActionResult class.")

### withMessage(message)

Sets the success or error message associated with the execution of the action.

#### Signature

public Messaging.ActionResult.Builder withMessage(String message)

#### Parameters

- **message**:
    
    Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")
    
    The notification message.

#### Return Value

Type: [Messaging.ActionResult.Builder](#apex_class_Messaging_ActionResult_Builder "Contains methods to build and validate an instance of the Messaging.ActionResult class.")

### withSuccess(success)

Sets a Boolean that informs the user whether the execution of the action was successful (true) or not (false).

#### Signature

public Messaging.ActionResult.Builder withSuccess(Boolean success)

#### Parameters

- **success**:
    
    Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")

#### Return Value

Type: [Messaging.ActionResult.Builder](#apex_class_Messaging_ActionResult_Builder "Contains methods to build and validate an instance of the Messaging.ActionResult class.")