Associate Functions with CRM

A practical guide to associating a Function with Zoho CRM through the four most common triggers.

 

You have written and tested your Function in the editor from the Quickstart help section. Now associate it with your CRM so it runs in response to the events you choose. This page covers the four most common ways to associate a Function with Zoho CRM.

Language note:

The walkthroughs below use Deluge to demonstrate argument mapping, where you explicitly declare arguments and map them to CRM fields using merge variables. If your Function is written in Java, Node.js, or Python, arguments are passed automatically via basicIO instead, and you do not need to map individual arguments manually. The trigger association steps (where to navigate, which action to select) remain the same regardless of language.

For the full list of all available trigger types (including Approvals, Related Lists, Signals, Widgets, and Client Scripts), see Triggers and Associations.

Workflow Rules

Use this when you want a Function to run automatically in response to a record events such as when a record is created, edited, deleted, or meets a specific condition.

How to associate:

  1. Navigate to Setup → Automation → Workflow Rules.
  2. Create a new rule or edit an existing one.
  3. Choose the module (e.g. Deals, Leads, Contacts) and define the trigger condition (e.g. "When a Deal is created," "When Stage changes to Closed Won").
  4. Under Instant Actions (or Scheduled Actions for delayed execution), click Function.
  5. Select your Function from the list.
  6. Map the arguments. For each Function argument, select the corresponding CRM field using a merge variable (e.g. ${Deals.Deal Name}, ${Deals.Amount})
  7. Save the Workflow Rule and ensure it is active.

The Function will now execute every time a record matches the rule's trigger condition. Since workflow Functions return void (execution is offloaded), the record save completes independently of the Function's execution.

Tip:

Test your Function in the editor first with hardcoded values that match what the workflow will pass. Once you're confident the logic works, wire it up to the rule.

Custom Buttons

Use this when you want users to trigger a Function manually by clicking a button on a CRM record page.

How to associate:

  1. Navigate to Setup → Customization → Modules and Fields.
  2. Select the module (e.g. Deals) and go to the Links and Buttons tab.
  3. Click the Create New Button.
  4. Configure the button. Give the button a name and choose where it appears: View Page, Create/Edit Page, or List View
  5. Under Action, select Writing a Function.
  6. Choose your Function from the list (or create one inline).
  7. Map each argument to CRM record fields, just like with workflow rules.
  8. Save the button and assign it to the relevant profiles that should view it.

When a user clicks the button, the Function executes and the return value (a String) is displayed as a modal dialog in the CRM UI. Use this to show confirmation messages, results, or error feedback.

Tip:

Button Functions are great for on-demand actions like generating a quote, syncing a record to an external system, or running a quick data validation before a sales rep proceeds.

Scheduled Functions

Use this when you want a Function to run automatically at regular intervals, independent of any user action or record event.

How to associate:

  1. Navigate to Setup → Developer Hub → Functions.
  2. Open or create a Function with the Schedule category.
  3. Click Schedules in the editor toolbar (or navigate to Setup → Automation → Schedules).
  4. Click the Create New Schedule.
  5. Give the schedule a name and select your Function.
  6. Configure the frequency: hourly, daily, weekly, monthly, or a custom interval.
  7. Set the start date/time and optionally an end date.
  8. Save and activate the schedule.

Scheduled Functions return void. They perform their work during execution, such as batch processing, data synchronization, report generation, or cleanup tasks, without returning a value.

Tip:

Scheduled Functions are ideal for recurring jobs like syncing CRM data with an external system overnight, sending weekly pipeline summary emails, or cleaning up stale records.

Blueprint Transitions

Use this when you want a Function to run automatically during a Blueprint transition, such as when a Deal moves from Qualification to Proposal.

How to associate:

  1. Navigate to SetupAutomationBlueprint.
  2. Open an existing Blueprint or create a new one for your module.
  3. In the Blueprint editor, click on the transition (the arrow between two states) where you want the Function to execute.
  4. Under the Actions tab of the transition configuration, select Function.
  5. Choose your Function and map arguments to CRM fields.
  6. Save the Blueprint.

The Function executes when a user (or automation) moves a record through that specific transition. Like Automation Functions, Blueprint Functions return void. They perform their work during the transition without returning a value.

Tip:

Blueprint Functions are useful for executing business logic during Blueprint transitions. For example, you can validate that all required fields are completed before allowing a Deal to move to Closed Won, or notify an external system when a record enters a specific state.

What's Next?

Now that your Function is associated with the CRM, you may want to: