Creating JavaScript Functions
JavaScript functions are small pieces of code you write once and reuse across ProcessPlan. They run in a secure, isolated environment and can be used to:
-
Run logic in an automated action with the JavaScript Function action type
-
Populate a drop down field’s options with the JavaScript Code Source field type
-
Give AI agents a custom capability they can call when the situation needs it
Functions are managed under Administration > Integrations > Code / Functions. The list shows each function’s Function Name, Modified By, Modified Date, and Last Used.
Create a function
Section titled “Create a function”-
Click the New Function icon at the top of the list
-
Enter a Function Name and save. The code editor and the sections below then appear
-
Write your code in the JavaScript Code editor. Every function must define an
executefunction:
async function execute(event, helpers) { // event.customerName - your parameter values as key/value pairs // helpers.http.get(url) - HTTP GET request (also post, put, delete) // helpers.env.API_KEY_NAME - access your saved secrets and environment variables
return { message: 'Hello from ProcessPlan code!', data: event, };}Description for AI Agent Mode
Section titled “Description for AI Agent Mode”The Description for AI Agent Mode field is a brief description of what the function does. Fill it in if you want AI agents to be able to use the function: the description is how an agent understands when the function is the right tool for the job.
Parameters
Section titled “Parameters”The Parameters section defines the inputs your function accepts. Wherever the function is used (an automated action, a field, an AI agent), each parameter appears as its own input.
Click the Add Parameter icon and complete:
-
Parameter Name - The property name used when passing values to the function (no spaces, case sensitive). Read it in your code as
event.yourParameterName -
Default Value (optional) - Used when no value is provided at runtime
-
Required - Check if the function should not run without this parameter
Environment variables and secrets
Section titled “Environment variables and secrets”Reference any of your saved secrets and environment variables in code as helpers.env.YOUR_VARIABLE_NAME. They are detected automatically and made available when the function executes, so API keys and shared settings never need to be pasted into the code itself.
Test your function
Section titled “Test your function”Click Run Test to save and run the function using the default parameter values. The output appears below the button, so you can confirm the function returns what you expect before connecting it to an action or a field.
Good to know
Section titled “Good to know”-
Functions must finish within 35 seconds
-
Functions run in an isolated environment and cannot load external modules (
requireandimportare not available) -
The Last Used field on the function shows the last time anything executed it