# Workflow Action - Custom Code

> TABLE OF CONTENTS Overview Action Name Action Description Action Details Example Overview The Custom Code action allows you to extend your workflow’s…

- Source: https://docs.ghlcustomercare.com/docs/workflows/integrations-workflow-actions/workflow-action-custom-code
- Section: Workflows / Integrations Workflow Actions
- Reading time: 2 min
- Images: 1, each explained below

---
**TABLE OF CONTENTS**

-   [Overview](#overview)
-   [Action Name](#action-name)
-   [Action Description](#action-description)
-   [Action Details](#action-details)
-   [Example](#example)

## Overview

The **Custom Code** action allows you to extend your workflow’s functionality by writing and executing custom JavaScript and Python code. You can include properties from previous steps, perform operations, and return the output to be used in subsequent steps.

## Action Name

**Custom Code**

## Action Description

The **Custom Code** action enables the execution of JavaScript and Python code within a workflow, allowing users to extend the system’s functionality. This action can process data and return output that can be used in the workflow’s subsequent steps.

## Action Details

![Action Details (image 1 of 1)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155074495634/original/32I8Cra3GWFsaRqtlzk0Pji7d-EbRFh9YA.png)

**Action Details (image 1 of 1)**

This screenshot appears in the "Action Details" section of "Workflow Action - Custom Code". The text alongside this image reads: The Custom Code action enables the execution of JavaScript and Python code within a workflow, allowing users to extend the system’s functionality. This action can process data and return output that can be used in the workflow’s subsequent steps. Immediately after, the guide continues: Action Name: Give your custom code step a name that reflects its purpose. Language: By default, this is set to JavaScript but you can select Python too from the dropdown Property to Include in Code: Code.
- What this covers: The Custom Code action enables the execution of JavaScript and Python code within a workflow, allowing users to extend the system’s functionality. This action can process data and return output that can be used in the workflow’s subsequent steps.
- Next: Action Name: Give your custom code step a name that reflects its purpose. Language: By default, this is set to JavaScript but you can select Python too from the dropdown Property to Include in Code: Code:

### **How to Configure**

1.  **Action Name:** Give your custom code step a name that reflects its purpose.
2.  **Language:** By default, this is set to JavaScript but you can select Python too from the dropdown
3.  **Property to Include in Code:**
    -   Add key-value pairs where the key will be used in your code, and the value can either be hardcoded or dynamically mapped from previous workflow steps.
    -   Use these key-value pairs within the code by referencing `inputData.<key>`. For example, if the key is `number1`, you can access it in the code as `inputData.number1`.
4.  **Code:**
    -   Write JavaScript/Python code to process the values mapped in the previous step.
    -   Ensure the output is in the form of a JavaScript/Python object or array of objects. Example: `output = { result: sum }`.

<table border="1" cellpadding="0" cellspacing="0" dir="ltr" style="width: 0px"><colgroup><col width="100"><col width="506"><col width="119"></colgroup><tbody><tr><td dir="ltr" style="vertical-align: bottom; text-align: center">Field Name</td><td style="vertical-align: bottom; font-weight: normal; text-align: center">Description</td><td style="vertical-align: bottom; font-weight: normal; text-align: center">Mandatory</td></tr><tr><td style="vertical-align: bottom; white-space: normal">Action Name</td><td style="vertical-align: bottom; white-space: normal">The name of the action that will be displayed in the workflow.</td><td style="vertical-align: bottom; font-weight: normal; white-space: normal">Yes</td></tr><tr><td style="vertical-align: bottom; white-space: normal">Language</td><td style="vertical-align: bottom; white-space: normal">The programming language used for the custom code (default is JavaScript).</td><td style="vertical-align: bottom; font-weight: normal; white-space: normal">Yes</td></tr><tr><td style="vertical-align: bottom; white-space: normal">Property To Include In Code</td><td style="vertical-align: bottom; white-space: normal">Fields to be used within the code, mapped from previous steps. Use inputData.keyName to access the values within the code.</td><td style="vertical-align: bottom; font-weight: normal; white-space: normal">Yes</td></tr><tr><td style="vertical-align: bottom; white-space: normal">Code</td><td style="vertical-align: bottom; white-space: normal">JavaScript code to perform the desired operation. The output should be a JavaScript object.</td><td style="vertical-align: bottom; font-weight: normal; white-space: normal">Yes</td></tr></tbody></table>

## Example

javascript

Copy code

`// This is wrapped in an async function const sum = inputData.number1 + inputData.number2;  // Return the result as a JavaScript object output = { result: sum };`

This example adds two numbers from the mapped properties `number1` and `number2` and outputs their sum.

---

Documentation for GHL Customer Care. Support: support@ghlcustomercare.com