# Workflow Action - Custom Code

> TABLE OF CONTENTS What is Custom Code? How it works 1. Add Action 2. Programming Language 3. Property to be included in code 4. Code Editor 5. Enhanced…

- Source: https://docs.ghlcustomercare.com/docs/workflows/workflow-builder/workflow-action-custom-code
- Section: Workflows / Workflow Builder
- Reading time: 5 min
- Images: 21, each explained below

---
**TABLE OF CONTENTS**

-   [What is Custom Code?](#what-is-custom-code)
-   [How it works](#how-it-works)
    -   [1\. Add Action](#1-add-action)
    -   [2\. Programming Language](#2-programming-language)
    -   [3\. Property to be included in code](#3-property-to-be-included-in-code)
    -   [4\. Code Editor](#4-code-editor)
    -   [5. Enhanced console support](#5-enhanced-console-support)
    -   [6\. External HTTP Request](#6-external-http-request)
    -   [7\. Format Code](#7-format-code)
    -   [8\. Test your Code](#8-test-your-code)[](#custom-code-ai)[](#custom-code-ai)[](#custom-code-ai)
    -   [Custom Code AI](#custom-code-ai)
        -   [Overview:](#overview)
        -   [Previous Behaviour:](#previous-behaviour)
        -   [What’s New?](#whats-new)
        -   [How to Use It?](#how-to-use-it)
        -   [Use Cases](#use-cases)
-   [Points to Remember](#points-to-remember)

# **What is Custom Code?**

Custom Code is a powerful tool that will allow users to create custom logic they want to achieve and are not available currently. This provides flexibility and control beyond the pre-built actions, enabling users to automate complex tasks and integrate with various services not natively supported. This is a Premium Action.

# **How it works**

## **1\. Add Action**

-   In the workflows select the "+" icon to add an action and search for "Custom Code".

## **  

![1. Add Action (image 1 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155024378232/original/WRJzyc6QLm9ZtRTV2p7zAeFh-pRxSKzRuw.png)

**1. Add Action (image 1 of 21)**

This screenshot appears in the "1. Add Action" section of "Workflow Action - Custom Code". The text alongside this image reads: In the workflows select the "+" icon to add an action and search for "Custom Code". Immediately after, the guide continues: The code can be written in JavaScript. This will be the default language selected.
- What to choose: In the workflows select the "+" icon to add an action and search for "Custom Code".
- Next: The code can be written in JavaScript. This will be the default language selected.

**

## **2\. Programming Language**

-   The code can be written in JavaScript. This will be the default language selected.

![2. Programming Language (image 2 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155024378127/original/vCWA7jTLsUWY_h-z1Ck3SO08t0yZYuihhw.png)

**2. Programming Language (image 2 of 21)**

This screenshot appears in the "2. Programming Language" section of "Workflow Action - Custom Code". The text alongside this image reads: The code can be written in JavaScript. This will be the default language selected. Immediately after, the guide continues: Now what if there are values in the triggers or actions above the custom code and you want to use them in the code. That's where this field comes to use. These fields allow us to reference values from previous steps in our code by adding….
- What this covers: The code can be written in JavaScript. This will be the default language selected.
- Next: Now what if there are values in the triggers or actions above the custom code and you want to use them in the code. That's where this field comes to use. These fields allow us to reference values from previous steps in our code by adding them to a dictionary called InputData. You can enter the Key in the "Key" input field and assign a value to it by selecting the value through the custom value picker. You can add multiple properties by clicking on "Add Property" For example, if a trigger gives us information about a customer, which we then need to manipulate, we can add their name to the Input Data fields and reference it with i inputData.keyName or inputData['keyName']

## **3\. Property to be included in code**

-    Now what if there are values in the triggers or actions above the custom code and you want to use them in the code. That's where this field comes to use.
-   These fields allow us to reference values from previous steps in our code by adding them to a dictionary called InputData.
-   You can enter the Key in the "Key" input field and assign a value to it by selecting the value through the custom value picker.
-   You can add multiple properties by clicking on "Add Property"
-   For example, if a trigger gives us information about a customer, which we then need to manipulate, we can add their name to the _Input Data_ fields and reference it with _iinputData.keyName or inputData\['keyName'\]_

![3. Property to be included in code (image 3 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155024378049/original/mkwVkOObW-V10c1bOgLQ0DJC0CQ4fjQ5qA.png)

**3. Property to be included in code (image 3 of 21)**

This screenshot appears in the "3. Property to be included in code" section of "Workflow Action - Custom Code". The text alongside this image reads: Now what if there are values in the triggers or actions above the custom code and you want to use them in the code. That's where this field comes to use. These fields allow us to reference values from previous steps in our code by adding them to a dictionary called InputData. You can enter the Key…. Immediately after, the guide continues: You can write the code in the Code Editor A sample code is pre populated for your reference. Output should also be written in the code formatter itself. Output should be a JavaScript Object or Array of Objects.
- What to fill in: Now what if there are values in the triggers or actions above the custom code and you want to use them in the code. That's where this field comes to use. These fields allow us to reference values from previous steps in our code by adding them to a dictionary called InputData. You can enter the Key in the "Key" input field and assign a value to it by selecting the value through the custom value picker. You can add multiple properties by clicking on "Add Property" For example, if a trigger gives us information about a customer, which we then need to manipulate, we can add their name to the Input Data fields and reference it with i inputData.keyName or inputData['keyName']
- Next: You can write the code in the Code Editor A sample code is pre populated for your reference. Output should also be written in the code formatter itself. Output should be a JavaScript Object or Array of Objects.

Full procedure:

1. Now what if there are values in the triggers or actions above the custom code and you want to use them in the code. That's where this field comes to use.
2. These fields allow us to reference values from previous steps in our code by adding them to a dictionary called InputData.
3. You can enter the Key in the "Key" input field and assign a value to it by selecting the value through the custom value picker.
4. You can add multiple properties by clicking on "Add Property"
5. For example, if a trigger gives us information about a customer, which we then need to manipulate, we can add their name to the Input Data fields and reference it with i inputData.keyName or inputData['keyName']

## **4\. Code Editor**

-   You can write the code in the Code Editor
-   A sample code is pre populated for your reference.
-   Output should also be written in the code formatter itself.
-   Output should be a JavaScript Object or Array of Objects.

![4. Code Editor (image 4 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155024378027/original/kHyz3pZI-RI9S0Ca4p1YvYPCBejYVve4_A.png)

**4. Code Editor (image 4 of 21)**

This screenshot appears in the "4. Code Editor" section of "Workflow Action - Custom Code". The text alongside this image reads: You can write the code in the Code Editor A sample code is pre populated for your reference. Output should also be written in the code formatter itself. Output should be a JavaScript Object or Array of Objects. This part of the guide covers 1 field, listed below. Immediately after, the guide continues: This feature captures and logs all console.log outputs from user code, allowing user to debug and monitor the code more effectively.
- What this covers: You can write the code in the Code Editor A sample code is pre populated for your reference. Output should also be written in the code formatter itself. Output should be a JavaScript Object or Array of Objects.
- Fields: You can write the code in the Code Editor
- Next: This feature captures and logs all console.log outputs from user code, allowing user to debug and monitor the code more effectively.

Full procedure:

1. You can write the code in the Code Editor
2. A sample code is pre populated for your reference.
3. Output should also be written in the code formatter itself.
4. Output should be a JavaScript Object or Array of Objects.

## **5.** **Enhanced console support**

This feature captures and logs all `console.log` outputs from user code, allowing user to debug and monitor the code more effectively.

![5. Enhanced console support (image 5 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155027875958/original/K0BsznDm80JrDaTX-UqXEfvu2vtqvIOWhw.png)

**5. Enhanced console support (image 5 of 21)**

This screenshot appears in the "5. Enhanced console support" section of "Workflow Action - Custom Code". The text alongside this image reads: This feature captures and logs all console.log outputs from user code, allowing user to debug and monitor the code more effectively. Immediately after, the guide continues: Custom code supports external HTTP requests Click on "HTTP Request" button above the code editor Select from the following - The selected request will populate at the bottom in the code editor.
- What this covers: This feature captures and logs all console.log outputs from user code, allowing user to debug and monitor the code more effectively.
- Next: Custom code supports external HTTP requests Click on "HTTP Request" button above the code editor Select from the following - The selected request will populate at the bottom in the code editor

## **6\. External HTTP Request**

-   Custom code supports external HTTP requests
-   Click on "HTTP Request" button above the code editor
-   Select from the following -
    -   Get Method
    -   Post Method
    -   Put Method
    -   Patch Method
    -   Delete Method
    -   Head Method
    -   Options Method
-   The selected request will populate at the bottom in the code editor

![6. External HTTP Request (image 6 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155031663651/original/NWpdt8gG-WfHVs1EiibGgGHoluVDhrgsmA.png)

**6. External HTTP Request (image 6 of 21)**

This screenshot appears in the "6. External HTTP Request" section of "Workflow Action - Custom Code". The text alongside this image reads: Custom code supports external HTTP requests Click on "HTTP Request" button above the code editor Select from the following - The selected request will populate at the bottom in the code editor. This part of the guide covers 6 fields, listed below. Immediately after, the guide continues: You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. Properly formatted code is easier to read and understand. For instance, consistent indentation….
- What to choose: Custom code supports external HTTP requests Click on "HTTP Request" button above the code editor Select from the following - The selected request will populate at the bottom in the code editor
- Fields: Custom code supports external HTTP requests, Get Method, Post Method, Put Method, Patch Method, Options Method
- Next: You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. Properly formatted code is easier to read and understand. For instance, consistent indentation, spacing, and line breaks help identify code blocks, functions, or sections of a document.

Full procedure:

1. Custom code supports external HTTP requests
2. Click on "HTTP Request" button above the code editor
3. Select from the following -
4. The selected request will populate at the bottom in the code editor

![6. External HTTP Request (image 7 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155031663702/original/Ob9Ll6kArI7ngGwSq70HnuiJ-UcNJ5nc0g.png)

**6. External HTTP Request (image 7 of 21)**

This screenshot appears in the "6. External HTTP Request" section of "Workflow Action - Custom Code". The text alongside this image reads: Custom code supports external HTTP requests Click on "HTTP Request" button above the code editor Select from the following - The selected request will populate at the bottom in the code editor. This part of the guide covers 6 fields, listed below. Immediately after, the guide continues: You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. Properly formatted code is easier to read and understand. For instance, consistent indentation….
- What to choose: Custom code supports external HTTP requests Click on "HTTP Request" button above the code editor Select from the following - The selected request will populate at the bottom in the code editor
- Fields: Custom code supports external HTTP requests, Get Method, Post Method, Put Method, Patch Method, Options Method
- Next: You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. Properly formatted code is easier to read and understand. For instance, consistent indentation, spacing, and line breaks help identify code blocks, functions, or sections of a document.

Full procedure:

1. Custom code supports external HTTP requests
2. Click on "HTTP Request" button above the code editor
3. Select from the following -
4. The selected request will populate at the bottom in the code editor

![6. External HTTP Request (image 8 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155031665905/original/4Da5WUEasD9nTmpu84KkQQfFfHeykeDoJg.png)

**6. External HTTP Request (image 8 of 21)**

This screenshot appears in the "6. External HTTP Request" section of "Workflow Action - Custom Code". The text alongside this image reads: Custom code supports external HTTP requests Click on "HTTP Request" button above the code editor Select from the following - The selected request will populate at the bottom in the code editor. This part of the guide covers 6 fields, listed below. Immediately after, the guide continues: You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. Properly formatted code is easier to read and understand. For instance, consistent indentation….
- What to choose: Custom code supports external HTTP requests Click on "HTTP Request" button above the code editor Select from the following - The selected request will populate at the bottom in the code editor
- Fields: Custom code supports external HTTP requests, Get Method, Post Method, Put Method, Patch Method, Options Method
- Next: You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. Properly formatted code is easier to read and understand. For instance, consistent indentation, spacing, and line breaks help identify code blocks, functions, or sections of a document.

Full procedure:

1. Custom code supports external HTTP requests
2. Click on "HTTP Request" button above the code editor
3. Select from the following -
4. The selected request will populate at the bottom in the code editor

## **7\. Format Code**

-   You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. 
-   Properly formatted code is easier to read and understand.
-   For instance, consistent indentation, spacing, and line breaks help identify code blocks, functions, or sections of a document.

![7. Format Code (image 9 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155040260049/original/2i2TDFNI9mLohJ2WLF-OAPHwbzYWsPt7FQ.png)

**7. Format Code (image 9 of 21)**

This screenshot appears in the "7. Format Code" section of "Workflow Action - Custom Code". The text alongside this image reads: You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. Properly formatted code is easier to read and understand. For instance, consistent indentation, spacing, and line breaks help identify code blocks, functions…. Immediately after, the guide continues: Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps. To test the code click on the "Test your Code" button. When you click on the button a new pop….
- What this covers: You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format. Properly formatted code is easier to read and understand. For instance, consistent indentation, spacing, and line breaks help identify code blocks, functions, or sections of a document.
- Next: Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps. To test the code click on the "Test your Code" button. When you click on the button a new pop up will open where you can run the test. There can be 2 scenarios, first where you have added properties and second where you have not. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response. In case there are no properties added, you can directly check the response. Click on the "Test your Code" button to check the response. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

Full procedure:

1. You can also format the code. Use the "Format Code" button in the bottom of the code editor to change the code into more readable format.
2. Properly formatted code is easier to read and understand.
3. For instance, consistent indentation, spacing, and line breaks help identify code blocks, functions, or sections of a document.

## **8\. Test your Code**

-   Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
-   To test the code click on the "Test your Code" button.
-   When you click on the button a new pop up will open where you can run the test.
-   There can be 2 scenarios, first where you have added properties and second where you have not.
-   In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
-   In case there are no properties added, you can directly check the response.
-   Click on the "Test your Code" button to check the response.
-   Post clicking on the test button, if there are no errors in the code them it will show "Test Result Success" and if there is an error in code then the result will be "Test Result Failed" and you would have to recheck the code to remove the error.  
    

![8. Test your Code (image 10 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155040704154/original/lnc7U0ylQXPQU2iUjFC1urV6_Mb0BMMvIQ.png)

**8. Test your Code (image 10 of 21)**

This screenshot appears in the "8. Test your Code" section of "Workflow Action - Custom Code". The text alongside this image reads: Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps. To test the code click on the "Test your Code" button. When you click on the button a new pop up will open where you can run the test. There can be 2…. Immediately after, the guide continues: 9. Check Input Values in Execution logs.
- What to fill in: Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps. To test the code click on the "Test your Code" button. When you click on the button a new pop up will open where you can run the test. There can be 2 scenarios, first where you have added properties and second where you have not. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response. In case there are no properties added, you can directly check the response. Click on the "Test your Code" button to check the response. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: 9. Check Input Values in Execution logs

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

![8. Test your Code (image 11 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155040704225/original/LFTyDgiuqeZ56sE6AoR7bBSsZOa4sDQVeA.jpeg)

**8. Test your Code (image 11 of 21)**

This screenshot appears in the "8. Test your Code" section of "Workflow Action - Custom Code". The text alongside this image reads: Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps. To test the code click on the "Test your Code" button. When you click on the button a new pop up will open where you can run the test. There can be 2…. Immediately after, the guide continues: 9. Check Input Values in Execution logs.
- What to fill in: Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps. To test the code click on the "Test your Code" button. When you click on the button a new pop up will open where you can run the test. There can be 2 scenarios, first where you have added properties and second where you have not. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response. In case there are no properties added, you can directly check the response. Click on the "Test your Code" button to check the response. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: 9. Check Input Values in Execution logs

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

![8. Test your Code (image 12 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155040704299/original/AFkt23K95-pVPzvItG697Rm9goHpeEv9uw.png)

**8. Test your Code (image 12 of 21)**

This screenshot appears in the "8. Test your Code" section of "Workflow Action - Custom Code". The text alongside this image reads: Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps. To test the code click on the "Test your Code" button. When you click on the button a new pop up will open where you can run the test. There can be 2…. Immediately after, the guide continues: 9. Check Input Values in Execution logs.
- What to fill in: Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps. To test the code click on the "Test your Code" button. When you click on the button a new pop up will open where you can run the test. There can be 2 scenarios, first where you have added properties and second where you have not. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response. In case there are no properties added, you can directly check the response. Click on the "Test your Code" button to check the response. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: 9. Check Input Values in Execution logs

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

**9\. Check Input Values in Execution logs**

-   Now check the input values in the Execution logs also.
-   Go to the execution you want to check the values for and click on more details.

![8. Test your Code (image 13 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155040260812/original/RgJrOqeucNAjU44v9pesVqODOUf6f7u54g.png)

**8. Test your Code (image 13 of 21)**

This screenshot appears in the "8. Test your Code" section of "Workflow Action - Custom Code". The text alongside this image reads: Now check the input values in the Execution logs also. Go to the execution you want to check the values for and click on more details. Immediately after, the guide continues: 10. R eturn a response directly from their custom code.
- What to fill in: Now check the input values in the Execution logs also. Go to the execution you want to check the values for and click on more details.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: 10. R eturn a response directly from their custom code.

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

![8. Test your Code (image 14 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155040260857/original/rbE0v-1cwhoPJWnMg0T5DsAaTTNISu9Flw.png)

**8. Test your Code (image 14 of 21)**

This screenshot appears in the "8. Test your Code" section of "Workflow Action - Custom Code". The text alongside this image reads: Now check the input values in the Execution logs also. Go to the execution you want to check the values for and click on more details. Immediately after, the guide continues: 10. R eturn a response directly from their custom code.
- What to fill in: Now check the input values in the Execution logs also. Go to the execution you want to check the values for and click on more details.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: 10. R eturn a response directly from their custom code.

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

10\. Return a response directly from their custom code.  

**Key Benefits:**

-   This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code.
-   This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts.

![8. Test your Code (image 15 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155028307901/original/Hq5-hpYYprjyTt27r2647tAzQvd185kgWQ.png)

**8. Test your Code (image 15 of 21)**

This screenshot appears in the "8. Test your Code" section of "Workflow Action - Custom Code". The text alongside this image reads: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts. Immediately after, the guide continues: Custom Code AI Overview: Writing custom code in workflows just got smarter, faster, and easier—thanks to AI! We’re thrilled to introduce Code with AI (Beta), enabling users to generate custom code snippets with just a simple description….
- What this covers: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: Custom Code AI Overview: Writing custom code in workflows just got smarter, faster, and easier—thanks to AI! We’re thrilled to introduce Code with AI (Beta), enabling users to generate custom code snippets with just a simple description. Previous Behaviour: What’s New? Pro Tip: Be as specific as possible in your prompt for the best results! How to Use It? Use Cases

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

### **Custom Code AI**

#### Overview:

Writing custom code in workflows just got smarter, faster, and easier—thanks to AI! We’re thrilled to introduce Code with AI (Beta), enabling users to generate custom code snippets with just a simple description.

#### Previous Behaviour:

-   Previously, creating custom code within workflows required users to write JavaScript code from scratch, which could be time-consuming and required programming expertise.
-   Manually map input properties from previous workflow steps to use within the code.
-   Test and debug code manually before implementation.
-   This process demanded a significant investment of time and technical skill.

#### What’s New?

-   Now we have AI-Assisted Code Generation. With Code with AI, the process is streamlined:
-   AI-Powered Code Generation – Describe the desired functionality in plain language, and AI will generate JavaScript code for you.
-   Automated Property Integration – AI intelligently incorporates relevant input properties based on your description.
-   One-Click Implementation – Quickly review and insert AI-generated code into your workflow.
-   Regenerate if Needed – Not happy with the first result? Click Generate again for a fresh version.

Pro Tip: 

Be as specific as possible in your prompt for the best results!

#### How to Use It?

-   Select: Choose Custom Code action in your workflow.

![How to Use It? (image 16 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155042527561/original/nAuVDOdQnA_E5f_4vFRoyZnV4uiwuuVPLQ.png)

**How to Use It? (image 16 of 21)**

This screenshot appears in the "How to Use It?" section of "Workflow Action - Custom Code". The text alongside this image reads: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts. Immediately after, the guide continues: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will….
- What this covers: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will be available for untested code in subsequent action. Use the Property fields to assign key names and map values from previous steps. Use inputData.keyName or inputData['keyName'] to access the values within the code.

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

-   Activate AI: Click "Build with AI" to open the AI assistant.

![How to Use It? (image 17 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155042527587/original/NGS2QkhHBqVWTPkey7Js2HHEO9y-OxhfMw.png)

**How to Use It? (image 17 of 21)**

This screenshot appears in the "How to Use It?" section of "Workflow Action - Custom Code". The text alongside this image reads: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts. Immediately after, the guide continues: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will….
- What this covers: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will be available for untested code in subsequent action. Use the Property fields to assign key names and map values from previous steps. Use inputData.keyName or inputData['keyName'] to access the values within the code.

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

-   Describe: Input your desired functionality (e.g., "I have an API that returns a date in MM-DD-YYYY format. Can you help me convert it to YYYY-MM-DD.").
-   Generate: Click Generate and let AI craft the code for you.

![How to Use It? (image 18 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155042527680/original/wHemORBiauxMu8J1jd5jKPyo-Ukw5r0AHg.png)

**How to Use It? (image 18 of 21)**

This screenshot appears in the "How to Use It?" section of "Workflow Action - Custom Code". The text alongside this image reads: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts. Immediately after, the guide continues: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will….
- What this covers: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will be available for untested code in subsequent action. Use the Property fields to assign key names and map values from previous steps. Use inputData.keyName or inputData['keyName'] to access the values within the code.

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

![How to Use It? (image 19 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155042527732/original/bbQ38-TfLfpWsC2KL8rjDbSwD0pjs1xVfA.png)

**How to Use It? (image 19 of 21)**

This screenshot appears in the "How to Use It?" section of "Workflow Action - Custom Code". The text alongside this image reads: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts. Immediately after, the guide continues: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will….
- What this covers: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will be available for untested code in subsequent action. Use the Property fields to assign key names and map values from previous steps. Use inputData.keyName or inputData['keyName'] to access the values within the code.

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

-   Regenerate - Want to make any changes in the Code, mention the changes in the text box and click on "Regenerate"

![How to Use It? (image 20 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155042527814/original/IdROuIKWKKyiOz_M_FaiBWIqEXTOuU2tsA.jpeg)

**How to Use It? (image 20 of 21)**

This screenshot appears in the "How to Use It?" section of "Workflow Action - Custom Code". The text alongside this image reads: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts. Immediately after, the guide continues: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will….
- What this covers: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will be available for untested code in subsequent action. Use the Property fields to assign key names and map values from previous steps. Use inputData.keyName or inputData['keyName'] to access the values within the code.

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

-   Implement: Review the output and click Use Code to insert it into your workflow.

![How to Use It? (image 21 of 21)](https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/155042527822/original/raFUyfiaiJllR7EUEYNmwx7IBk8zZpL5tw.jpeg)

**How to Use It? (image 21 of 21)**

This screenshot appears in the "How to Use It?" section of "Workflow Action - Custom Code". The text alongside this image reads: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts. Immediately after, the guide continues: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will….
- What this covers: This improvement allows for a more streamlined coding experience, making it easier to write, debug, and manage custom asynchronous code. This new capability simplifies handling asynchronous operations and improves the overall efficiency of custom scripts.
- Controls: 9. Check Input Values in Execution logs, Custom Code AI
- Next: Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing. Testing the code is mandatory. No output will be available for untested code in subsequent action. Use the Property fields to assign key names and map values from previous steps. Use inputData.keyName or inputData['keyName'] to access the values within the code.

Full procedure:

1. Testing the code is a mandatory step, if the test is not done then user will not be able to use the output of the code in the subsequent steps.
2. To test the code click on the "Test your Code" button.
3. When you click on the button a new pop up will open where you can run the test.
4. There can be 2 scenarios, first where you have added properties and second where you have not.
5. In case there are properties are added you can enter the sample values in the "Test Setup" tab and test the Response.
6. In case there are no properties added, you can directly check the response.
7. Click on the "Test your Code" button to check the response.
8. Post clicking on the test button, if there are no errors in the code them it will show " Test Result Success " and if there is an error in code then the result will be " Test Res ult Failed" and you would have to recheck the code to remove the error.

#### Use Cases

-   Data Formatting – Automatically format phone numbers or dates to match your preferred style.
-   API Integration – Generate code to connect with external services via HTTP requests.
-   Mathematical Calculations – Compute interest rates, discount percentages, or other formulas dynamically.
-   String Manipulation – Extract key details from text, such as email addresses from subject lines.
-   Conditional Logic – Implement custom decision-making processes, like routing leads based on specific criteria.

# **Points to Remember**

-   Custom value will not be passed when you are testing your code.Only the contact information will be passed when testing a code. Other properties used in the code will not pass while testing.
-   Testing the code is mandatory. No output will be available for untested code in subsequent action.
-   Use the Property fields to assign key names and map values from previous steps. Use inputData.keyName or inputData\['keyName'\] to access the values within the code.

---

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