Write Your First Function

A beginner-friendly walkthrough to create, run, and save your first Standalone Deluge Function.

 

This quickstart gets you from zero to a running Function in a few minutes. You will create a simple Standalone Function, write a short Deluge script, run it in the editor, and view the output, all without configuring CRM automation or triggers.

By the end you will be familiar with the Functions editor, the create-run-save workflow, and how info statements help you debug.

What We're Building

Scenario: A Standalone Function that takes a person's name as input and prints a personalized greeting to the console.

This example is deliberately simple. The goal is to learn the editor and execution flow before moving on to real CRM automations.

Step 1: Navigate to the Functions Page

Navigate to Setup → Developer Hub → Functions and click Create Function. Functions Landing Page

Step 2: Create the Function

Fill in the creation form:

  • Language: Deluge
  • Name: Hello Greeter
  • Function Name: hello_greeter
  • Description: A simple greeter Function for learning the editor
  • Category: Standalone

Create Standalone Function

Why Standalone?

Use the Standalone category to create a general-purpose Deluge function that is not associated with a specific CRM event. This category is available only for Deluge functions. It can run independently, be called by other functions, or be exposed as API endpoints.

See Function Categories for all the options and when to use each one.

Click Create. The Functions editor opens.

Step 3: Define an Argument

The Function needs a name to greet. In the Arguments panel on the left side of the editor, add:

Argument NameType
userNameString

This argument will be accessible inside your script. When you run the Function, the editor will prompt you to provide a value for it.

Define Argument

Note:

Arguments can also be declared directly in the Function signature in the code area (e.g. string standalone.hello_greeter(string userName)). The Arguments panel and the code signature stay in sync. You can use whichever you prefer.

Step 4: Write the Script

The editor pre-populates the Function declaration in the format:

 

<return_type> <category>.<function_name>(<arguments>)

Replace the editor contents with:

 

string standalone.hello_greeter(string userName)
{
    // Build a greeting message
    greeting = "Hello, " + userName + "! Welcome to Zoho CRM Functions.";

    // Print to the Console for verification
    info greeting;

    // Return the greeting as output
    return greeting;
}

What's happening here:

  • userName is the argument you defined. Its value is passed to the Function when it runs.
  • info prints output to the Console panel on the right side of the editor during testing, and to the Function's execution logs when the Function runs in production, making it useful for both development and debugging live executions.
  • return sends the greeting string back as the Function's output. Standalone Functions return a string by default.

Step 5: Run and Verify

  1. Click Run in the editor toolbar.
  2. When prompted, enter a test value for userName. For example,Boyle.
  3. Check the Console on the right side of the editor.

Run Standalone Function

You should see:

 

Hello, Boyle! Welcome to Zoho CRM Functions.

If you see an error instead, check for the script typos. The Console shows the line number and error details to help you identify the problem.

Tip:

Use info statements liberally while developing. They appear in the Console during editor testing and in the Function’s execution logs when the Function is invoked by a workflow, button, or schedule. This makes them useful for debugging in both development and production.

Step 6: Save the Function

Once the output looks correct, click Save. The editor automatically creates a revision snapshot. You can browse the complete change history and restore any previous version at any time from the Revisions menu.

The Function is now saved and ready. At this point, you could associate the Function with a trigger, call it from another Function, or expose it as an HTTP endpoint. You will learn about these options in the next quickstart. Save Standalone Function

What You Just Learned

  • Creating a Function from SetupDeveloper HubFunctions by specifying it's language, name, and category.
  • Categories determine where a Function can be used. Choose Standalone for reusable logic, Automation for workflow triggers, Button for user-initiated actions, and Schedule for time-based jobs.
  • Arguments define the input your Function accepts. Declare them in the Arguments panel or directly in the Function signature in the code editor.
  • info prints output to the Console during testing and to the execution logs in production. Use it to verify values and debug your function at every stage.
  • return sends a value back as the Function's output. The return type depends on the Function category. For example, Standalone returns String by default.
  • Revision history is created automatically. Every save creates a snapshot that you can restore later.

What's Next?

You have created and run your first Function.