Zoho CRM: Execute Function with a Button

11.25.21 10:07 AM By Andy

In this tutorial we are going to create a button that will trigger a function after we select some records. You can trigger any function you want, but for this example we are going to keep things simple. The button will trigger a function that updates a field.

Part 1: Creating the function

  1. In the set up page, click on "functions" under "developer space"
  2. Click on the "new function" button
  3. Name the function and select Button as the category
  4. Copy the code down below and paste it in the function's body
  5. Highlighted in yellow you will find the part of the function you can replace with your own function.
  6. Now click on "Edit Arguments" and map the argument "id" as a "string"
    1. If you added your own function that has variables, map them in the arguments section as well
  7. Finally save the arguments and save the function
idList = id.toList("|||");
for each id in idList
{
currentDate = today;
update = zoho.crm.updateRecord("Deals",id,{"Contract_signed":currentDate});
}
return "Contract signed date updated";

Part 2: Creating the button

  1. In the setup page, go to "Modules and fields" under "Customization"
  2. Open the module that you are creating the function for. In my case it's the Deals module
  3. On the top, click on "Links and Buttons"
  4. Click on "New Button"
  5. Name the button and add a description if you would like to
  6. Select "List View - Mass Action Menu" as the place were the button is going to be located
  7. The action to perform is "From Existing Actions" under "Functions"
  8. Now click on "Configure" next to the function you just created
  9. Map the "id" parameter to the Deal Id field, pressing #
  10. Save everything and test the button