Function #43: Transfer record information from one module to another with subform datas.

Function #43: Transfer record information from one module to another with subform datas.


 

Welcome back everyone!

 

Last week, we learnt how to Organize Contacts based on the Deal Stages. This week, let's look at a custom function that lets you transfer data captured from one module to the other along with the subform data.

 

Business scenario: 

 

The standard sales process involves entering the leads acquired through various channels to the CRM followed by lead qualification and conversion. The process is quite linear - create a lead --> qualify the lead --> convert it to contact --> create an account --> create a deal --> follow up with prospect --> win the deal. However, the sale process need not be linear on all occasions. What if your process involves copying CRM records from one module to the other seamlessly?  Say for instance, you run a gaming company that follows freemium business model. The case involves 2 categories of users namely free and paid. . By default, the free customers are captured in the Leads module. Use the Function I'm sharing today to copy the records from the Leads module to the "Paid Customers" module once the user upgrades to the paid version. The best part is that the code copies not only the data from the standard and custom fields but also the data tracked using the sub-forms. Just need to ensure that the source and destination have the same subform fields and field types.

 

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.


Getting started with the custom function:

  • Go to Setup > Automation > Actions > Functions > Configure Function > Write your own.
  • Provide a name for the custom function. For example: “Create Paid Customer”. Add a description(optional).
  • Select the module as Deal. Add a description (optional).
  • Copy the code given below.
  • Click “Edit arguments”.
  • Enter the name as “leadId” and select the value as “Lead Id”.
  • Save the changes.

 

The Code: 

 

respMap = zoho.crm.getRecordById("Leads",leadId.toLong());

//info respMap;

mp = Map();

mp.put("Name",ifnull(respMap.get("Full_Name"),""));

mp.put("Division",ifnull(respMap.get("Division"),""));

mp.put("Project_Number",ifnull(respMap.get("Project_Number"),""));

mp.put("Customer_Name",ifnull(respMap.get("Account_Name"),""));

mp.put("Exchange_Rate",ifnull(respMap.get("Exchange_Rate"),""));

mp.put("Base_Currency",ifnull(respMap.get("Base_Currency"),""));

mp.put("Billing_Street",ifnull(respMap.get("Billing_Street"),""));

mp.put("Billing_State",ifnull(respMap.get("Billing_State"),""));

mp.put("Billing_Country",ifnull(respMap.get("Billing_Country"),""));

mp.put("Billing_Code",ifnull(respMap.get("Billing_Code"),""));

mp.put("Billing_CIty",ifnull(respMap.get("Billing_City"),""));

sub_forms = List();

subinfo = ifnull(respMap.get("Product_Details"),"");

//info subinfo;

for each rec in subinfo

{

subform = Map();

subform.put("Product",eachProd.get("product").get("id"));

subform.put("Quantity",rec.get("quantity"));

sub_forms.add(subform);

//info sub_forms;

}

mp.put("Product_Details",sub_forms);

create = zoho.crm.create("Paid_Users",mp,{"trigger":["workflow"]});

info create;

 

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

 

Use the code to transfer information between any two modules. Update the module's api' names in the code accordingly.

Similar to "ID" of a record, the "ID" for a Custom Module is "CustomModule1", "CustomModule2", etc, in the order of creation. 

The code given above works only for V2 version of Zoho APIs. Please note that the code WILL NOT work for Version 1.0 APIs.

 

Found this useful? Try it out and let me know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful. Do check out other custom functions shared in this series here

 

See you all next week with another interesting custom function. Ciao!

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now