---
schema_version: "1"
id: 076fe5b4a4138486a73cbafb93a7074aa53731a97a0bfb95ec1ef34694e52242
title: Configure the Client-Side Controller for a Flow Local Action
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/components/components-config-for-flow-actions-controller.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/components-config-for-flow-actions-controller.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 14a4edd7e04cf1eb19aab55f38156fcf0c4c665436346558da7cfe6cadb47482
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# Configure the Client-Side Controller for a Flow Local Action

When a component is executed as a flow local action, the flow calls the `invoke` method in the client-side controller. To run the code asynchronously in your client-side controller, such as when you're making an XML HTTP request (XHR), return a Promise. When the method finishes or the Promise is fulfilled, control is returned back to the flow.

## Asynchronous Code

When a Promise is resolved, the next element in the flow is executed. When a Promise is rejected or hits the timeout, the flow takes the local action's fault connector and sets `$Flow.FaultMessage` to the error message.

By default, the error message is “An error occurred when the elementName element tried to execute the c:myComponent component.” To customize the error message in `$Flow.FaultMessage`, return it as a new Error object in the `reject()` call.

```javascript
({
   invoke : function(component, event, helper) {
      return new Promise(function(resolve, reject) {
         // Do something asynchronously, like get data from
         // an on-premise database

         // Complete the call and return to the flow
         if (/* request was successful */) {
            // Set output values for the appropriate attributes
            resolve();
         } else {
            reject(new Error("My error message")); }
      });
   }
})
```

**note:** If you’re making callouts to an external server, add the external server to the allowlist in your org and enable or configure CORS in the external server.

## Synchronous Code

When the method finishes, the next element in the flow is executed.

```javascript
({
   invoke : function(component, event, helper) { 
      // Do something synchronously, like open another browser tab
      // with a specified URL

      // Set output values for the appropriate attributes
    }
 })
```

**See Also**  


-   [*Component Library*: lightning:availableForFlowActions Interface](https://developer.salesforce.com/docs/component-library/bundle/lightning:availableForFlowActions/documentation)

-   [Cancel an Asynchronous Request in a Flow Local Action](https://developer.salesforce.com/docs/platform/aura-platform/guide/components-config-for-flow-actions-abort.md)
-   [Using External JavaScript Libraries](https://developer.salesforce.com/docs/platform/aura-platform/js/js-libs-platform.md)

