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
- In the set up page, click on "functions" under "developer space"
- Click on the "new function" button
- Name the function and select Button as the category
- Copy the code down below and paste it in the function's body
- Highlighted in yellow you will find the part of the function you can replace with your own function.
- Now click on "Edit Arguments" and map the argument "id" as a "string"
- If you added your own function that has variables, map them in the arguments section as well
- 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
- In the setup page, go to "Modules and fields" under "Customization"
- Open the module that you are creating the function for. In my case it's the Deals module
- On the top, click on "Links and Buttons"
- Click on "New Button"
- Name the button and add a description if you would like to
- Select "List View - Mass Action Menu" as the place were the button is going to be located
- The action to perform is "From Existing Actions" under "Functions"
- Now click on "Configure" next to the function you just created
- Map the "id" parameter to the Deal Id field, pressing #
- Save everything and test the button