Function-26: Update information between two modules via Lookup fields.

Function-26: Update information between two modules via Lookup fields.




Welcome back everyone!

Last week, we learnt how to populate the Amount field in a Deal by calculating the number of products and its unit price. This week, let's look at a custom function that updates information between two modules via Lookup fields.

Business scenario:

Quotes are binding agreements between a customer and a vendor, to deliver the requested products to the customer within a specified time-frame at a predefined price. Your customers can place orders within a stipulated period (validity date) that has been mentioned in the quote, otherwise you may cancel or extend the time-frame by sending a new quote. In general, a Quote contains the Quote Number, Date, Line Items(Products) inclusive of quantity and prices based on your Price Books, Terms & Conditions and Description.

And incidently, the quote can be sent to a specific Contact or an Account. Depending on the scenario, the information to be on the quote may differ. For instance, you may want to add the Contact Phone number, Email address, Description or any information in a custom field to the quote. The Quotes module indeed has a lookup field for Contact, Deal and Account. Meaning, the information from a Contact, Deal or an Account can be copied automatically to a Quote through the lookup. So where does this custom function fit in?

It's for the information fields which are not available in a Quote. Information which is not normally available to be stored in the CRM can be stored using a custom field. Similarly, the modules Quotes, Invoice and modules like that have to be updated to store that additional information too. Are you going to juggle between modules to copy each additional information when a lookup is already available?

The custom function for today latches on to the Lookup field and whenever a Contact is selected as a lookup, the custom fields specified in the custom function are also transferred automatically. Furthermore, this custom function is not limited to the Quotes module. You can use this function to any module that has a Lookup field.

Getting started with the custom function:

  • Go to Setup > Automations > Actions > Custom Functions > Configure Custom Function > Write your own.
  • Provide a name for the custom function. For example: “Contact Lookup-1”. Add a description(optional).
  • Select the module as Quote. Add a description(optional).
  • Click “Free flow scripting”.
  • Copy the code given below.
  • Click “Edit arguments”.
  • Enter the name as “quoteId” and select the value as “Quote Id”.
  • Enter the name as "contId" and select the value as "Contact Id".
  • Save the changes.

The script:

Code for Version 2.0 API:

contDetails = zoho.crm.getRecordById("Contacts", input.contId.toLong());
mp=map();
mp.put("First_Name",ifnull(contDetails.get("First_Name"),""));
mp.put("Last_Name",ifnull(contDetails.get("Last_Name"),""));
mp.put("Broker_First_Name",ifnull(contDetails.get("Broker_First_Name"),""));
mp.put("Broker_Last_Name",ifnull(contDetails.get("Broker_Last_Name"),""));
mp.put("Property_Street",ifnull(contDetails.get("Property_Street"),""));
mp.put("Property_City",ifnull(contDetails.get("Property_City"),""));
mp.put("Property_State",ifnull(contDetails.get("Property_State"),""));
mp.put("Property_Zip",ifnull(contDetails.get("Property_Zip"),""));
updateResp= zoho.crm.update("Quotes",input.quoteId.toLong(), mp);
info mp;
info updateResp; 

Code for Version 1.0 API:

quoteIdStr = input.quoteId.toString();
contDetails = zoho.crm.getRecordById("Contacts", input.contId);
mp=map();
mp.put("First Name",ifnull(contDetails.get("First Name"),""));
mp.put("Last Name",ifnull(contDetails.get("Last Name"),""));
mp.put("Broker First Name",ifnull(contDetails.get("Broker First Name"),""));
mp.put("Broker Last Name",ifnull(contDetails.get("Broker Last Name"),""));
mp.put("Property Street",ifnull(contDetails.get("Property Street"),""));
mp.put("Property City",ifnull(contDetails.get("Property City"),""));
mp.put("Property State",ifnull(contDetails.get("Property State"),""));
mp.put("Property Zip",ifnull(contDetails.get("Property Zip"),""));
updateResp= zoho.crm.updateRecord("Quotes", quoteIdStr, mp);
info mp;
info updateResp;

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 "Create or Edit" in the "When do you want to execute this rule?".
  • Select the Condition as "All Records" and click Next.
  • Choose "Custom Function" from Instant Actions.
  • Select the option "Custom Function" (Created by users from your organization).
  • Select the required custom function and click Publish.
  • Provide a Description for the custom function and Publish it.
  • Save the workflow.

Note:

  • You can use the code on any module. Change the name of the module from 'Quotes' to whichever module you prefer and update the code accordingly.
  • The Fields in the left section (right after mp.put) of the code are the destination fields and the ones in the right are the source fields. Update your code according to your requirement and your fields.
  • If there is a need to copy information from a custom field, you need to create that custom field for the destination module too.

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!

Update: As you must be aware, API V1.0 will be deprecated and support for version 1.0 API will be available only till Dec 31, 2018. Version 1.0 compatible Functions will continue to work until Dec 31, 2019. You're advised to migrated to API Version 2.0 at the earliest. Check this announcement for more. We've updated the post to include the Version 2.0 compatible Function.
    • Sticky Posts

    • Custom Function: Tracking the Case Closed time

      Scenario: Tracking the Case Closed time   We create cases and close them but how do we keep track of the details on when the case was closed? This custom function helps you track the closed time of a case, in a custom date-time field. You can then generate reports based on the closed time. You need to have a custom date time field to update the Closed Time. Please follow these steps: Log in to Zoho CRM with administrative privileges. Click Setup > Automation > Workflow > Create Rule. In the New Rule
    • Function-2: Round-Robin assignment of records

      Welcome back folks! Last week, we saw how to update sales commission in quotes using a custom function. This week, let's see an interesting use case asked by many of you - auto-assignment records by round-robin method. Business scenario: Right now, the solution allows you to auto-assign leads from web form and imported lists. Let us look at a need where you want to auto-assign leads from in-bound calls in a round-robin method, across modules. Prerequisite: You must create a permanent record in the
    • Function #37: Create a Purchase Order from a Quote

      Welcome back everyone! Last week, we learnt how to calculate the total number of activities for a lead and further take note of the activity count for particular dates. For instance, from the period of Demo to Negotiation. This week, let's look at a function that lets you create a Purchase Order instantly from a Quote. Business scenario: In any form of business, one of the most important things to do is to document the transactions. Naturally, negotiation, signing an agreement, placing an order,
    • Function-1: Compute and update sales commission in quotes.

        Welcome back folks! In this week's custom functions series, we've picked a requirement that has often been asked by users! Business requirement: In most sales organizations, commissions are an integral part of the extrinsic rewards program, contributing significantly to the sales person’s compensation package. Sales commission is usually calculated as a percentage of revenue generated by the sales person. What if your sales team is enabled with an option to check their sales commission associated
    • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

      Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such

      Zoho SalesIQ Resources



            Zoho TeamInbox Resources

              Zoho DataPrep Resources


                  Zoho CRM Plus Resources

                    Zoho Books Resources


                      Zoho Subscriptions Resources

                        Zoho Desk Resources

                          Zoho Projects Resources


                            Zoho Sprints Resources


                              Qntrl Resources


                                Zoho Creator Resources


                                  Zoho WorkDrive Resources




                                      Zoho Campaigns Resources

                                        Zoho CRM Resources

                                                    Design. Discuss. Deliver.

                                                    Create visually engaging stories with Zoho Show.

                                                    Get Started Now


                                                      Zoho Show Resources


                                                        Zoho Writer Writer

                                                        Get Started. Write Away!

                                                        Writer is a powerful online word processor, designed for collaborative work.

                                                                    有料プランをご利用の方