What we are going to do
In this tutorial you are going to code a Deluge function that will create a related record in Zoho CRM. Then, we are going to add the function to a workflow, so it creates the record automatically. For this example, we are going to use the Deals module, that will trigger the automation, and a Custom module called Jobs, where the related record is going to be created. Both records are going to be linked.
- The modules you want to use have to be already built. If you want to learn how to create a custom module, here's a tutorial: https://youtu.be/B-b_5qg1FpI
- The child module must already contain the fields to receive information from the main module.
Adding a Lookup field
- In the Zoho CRM settings, go to "Modules and Fields", and open the "child" module that you are going to link to the main module. In this case, we are going to open the Jobs module, that will be linked to the Deals module.
- Open the layout where you are going to add the lookup field.
- Drag and drop the lookup field to the layout.
- Configure the lookup field:
- Name the field.
- Select the lookup module. In our case, it it's the Deals module.
- Name the related list. This is going to be displayed on the main module. We are going to call it "Jobs".
- Click on "Done".
- Save the layout and close it.
Setting up the function
- In the Zoho CRM settings, go to "Functions" under "Developer Space".
- Create a new function: Add a name and select "Automation" as the category.
- Copy the function located below and paste it in the text editor in Zoho CRM.
- Edit the arguments: add "deal_id" as a string.
- Get the Deal variables to pass to the Job:
- Find the API Names in the CRM settings.
- Map the variables using the Job module API Names.
- Make sure to include the "deal_id", so the records link to each other.
- Test the function.
- Save the function.
Creating a workflow
- In the setup page, click on workflow rules under automations
- Create a new rule, select the Deals module, and name it (we are selecting the Deals instead of the contact because we need to trigger this automation when a Deal stage changes)
- Configure your workflow trigger and conditions:
- When > on a record action > Edit > Stage is modified to the value of Won
- Condition: all Deals
- As the instant action, select "function"
- Click on "new function" and then select "functions"
- Find the function you just created, and click on "configure"
- Map the argument "deal_id" as the deal ID, using the # key
- Click on "save and associate" and save the workflow
- Test the workflow