Transfer record information from one module to another, based on specific criteria.

Business scenario:

Custom Modules enable you to create entire modules according to your requirements. You can also define the layout of the record in the module, set up layout rules, customize the fields of a record, set up hyperlinks and buttons, etc. This helps reduce clutter and organize your business information efficiently.

The custom function for today is quite similar to Lead Conversion. The difference is that it performs the conversion task on any modules. For instance, let's say you run a gaming company and have 2 custom modules, named Free Customers and Paid Customers. Set the custom function to automatically transfer the lead information to a record in the Free Customers module after making contact with the lead.

Create a Picklist named "Paid" with options "Yes" and "No". Tie the custom function I'm sharing today to this Picklist - I"ll tell you how to do it - such that the custom function gets invoked if "Yes" is picked. Set the default value to be "No" and leave the record as is if the customer prefers using the free plan. However, if the customer agrees to upgrade to paid plan, update the Picklist as "Yes". This invokes the custom function and moves the record to the Paid Customers module.This takes your business process automation taken to a whole new level.

Include this custom function in a Workflow Rule by setting the condition as "This workflow will be executed whenever the field Paid is updated." Alternatively, set a Custom Button to execute this custom function upon click.

Getting started with the function:

Step 1 : From Leads to a Custom Module

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Business Automation 01".
  3. Select the moduleto be associated as Tasks. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "leadId" and select the value as "Lead Id".
  7. Click Save & Execute Script.
  8. Save the changes.

The code:

For v2 Editor - DRE:


leadIdLong = input.leadId.toLong();
leadDetails = zoho.crm.getRecordById("Leads",leadIdLong);
mp = map();
mp.put("Name",ifnull(leadDetails.get("Full_Name"),""));
mp.put("Annual_Revenue", ifnull(leadDetails.get("Annual_Revenue"),""));
mp.put("Billing_City", ifnull(leadDetails.get("City"),""));
mp.put("Billing_Country", ifnull(leadDetails.get("Country"),""));
mp.put("Description", ifnull(leadDetails.get("Description"),""));
mp.put("Fax", ifnull(leadDetails.get("Fax"),""));
mp.put("Industry", ifnull(leadDetails.get("Industry"),""));
mp.put("Employees", ifnull(leadDetails.get("No_of_Employees"),""));
mp.put("Phone", ifnull(leadDetails.get("Phone"),""));
mp.put("Rating", ifnull(leadDetails.get("Rating"),""));
mp.put("Billing_State", ifnull(leadDetails.get("State"),""));
mp.put("Billing_Street", ifnull(leadDetails.get("Street"),""));
mp.put("Billing_Code", ifnull(leadDetails.get("Zip_Code"),""));
mp.put("Website", ifnull(leadDetails.get("Website"),""));
create = zoho.crm.create("CustomModule1apiname", mp);
info mp;
info create;

Step 2 : From one Custom Module to another

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Business Automation 02".
  3. Select the moduleto be associated as Tasks. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "CustommoduleId" and select the value as "CustomModule Id".
  7. Click Save & Execute Script.
  8. Save the changes.

The code:

For v2 Editor - DRE:


CustommoduleDetails = zoho.crm.getRecordById("CustomModule1apiname", input.CustommoduleId.toLong());
createMap = map();
createMap.put("Name", ifnull(CustommoduleDetails.get("Name"),""));
createMap.put("Owner", ifnull(CustommoduleDetails.get("Owner"),"").get("id"));
createMap.put("Phone", ifnull(CustommoduleDetails.get("Phone"),""));
createMap.put("Email", ifnull(CustommoduleDetails.get("Email"),""));
createCustomModule = zoho.crm.create("CustomModule2apiname", createMap);
info createMap;
info createCustomModule;

Adding to a workflow:

  • Go to Setup > Automation > Workflow Rules.
  • Click '+ Create Rule'.
  • Select the Module for which this custom function has to be added and give it a name and a description(optional).
  • Select "On a record action".
  • Select "Field Update" and click on Next.
  • Select the Condition as "Paid".
  • Select the checkbox "Repeat this workflow whenever a record is edited." and Click Next.
  • Choose "Custom Function" from Instant Actions.
  • Select the option "Custom Function" (Created by users from your organization).
  • Select the custom function you just added and click on Configure.
  • Click on "Save and Associate".
  • Save the workflow.

Note:

  • The above code works only for API V2.0 and not the previous version.
  • Use the code to transfer information between any two modules. Update the module names in the code accordingly.
  • Replace 'CustomModule1apiname' and 'CustomModule2apiname' with the actual api names of the custom modules.
  • Similar to "ID" of a record, the "ID" for a Custom Module is "CustomModule1", "CustomModule2", etc, in the order of creation. For instance, if Free Customers is created first and Paid Customers is second. Then ID of Free and Paid Customers is CustomModule1 and CustomModule2 respectively.
  • Create a Custom Field in the 1st module named "Date Created", or any name for that matter. It helps you to keep track of when you made contact with the customer, rather than the date in which the record in the 2nd module was created, which leads to discrepancies. Since the 2 modules are the same, creating this custom field lets you to know when the customer was contacted and when he turned into a "Paid Customer".

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips