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
Add Action
In the workflows select the "+" icon to add an action and search for "Custom Code".Programming Language
The code can be written in JavaScript. This will be the default language selected.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 inputData.keyName or inputData['keyName'].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.Enhanced console support
This feature captures and logs all console.log outputs from user code, allowing users to debug and monitor the code more effectively.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.
Test your Code
Testing the code is a mandatory step; if the test is not done, then users will not be able to use the output of the code in the subsequent steps.
To test the code click on the "Run Test" button.
After clicking on the Run test button, if there are no errors in the code, it will show "Test Result Success", and if there is an error in the code, then the result will be "Test Result Failed", and you would have to recheck the code to remove the error.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.
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.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article