Function-14: Get record owner details inside a record with the click of a button

Function-14: Get record owner details inside a record with the click of a button

Welcome back everyone! 

Last week, we learnt how to display grand total of Invoices in words. This week, let's look at a custom function that helps you fetch the details of a record owner inside a record with the click of a button.

Business scenario:

Lot of factors lead to a winning deal. Besides the obvious of being the first of the vendors to reach out to a prospect and closely following up without overwhelming the potential customer, and arranging for timely presale support, the processes followed internally either add to or slow down the efficiency. One such internal process is for the sales manager to have visibility into the details of who is following up on a particular prospect. Let's assume the sales manager gets a call from a prospect. You'd appreciate having all the information on the sales person who is following up on the sale as well. This visibility empowers the sales manager to engage with the prospect with more clarity. Be it an escalation or an usual query from the prospect, the call ends more fruitfully. 

Here's a custom function that makes your job easier by, letting you add the lead owner information to the lead record using custom fields. Now, when you report you can classify them based on the sales person who handled the lead or the profiles(Designations e.g. Administrators, Standard). 

The capabilities of this custom function does not stop here. The goal is to fetch the employee details and add them to records in modules to indicate the record owner. For companies with a huge sales team, sometimes panning across products or branches, this custom function comes handy.
Getting started with the custom function:
  • Go to Setup > Customization > Modules > Select the required module > Links and Buttons > +Create new button.
  • Provide a name for the button. For example: “Add Record Owner information”. Add a description(optional).
  • Choose View page from the drop-down list.
  • Select Writing custom function from the subsequent drop-down.
  • Provide a name for the custom function. Add a description(optional).
  • Click “Free flow scripting”.
  • Copy the code given below.
  • Click “Edit arguments”.
  • Enter the name as “leadId” and select the value as “Lead Id”.
  • Save the changes.
  • Change the 'xxxxxxxxxxxxxxxxx' with your crm authtoken .
  • Click Save to create the button.

The script:

Code for Version 2.0 API:
 
Arguments : 

record owner id - name it as 'ownerid'
record id - name it as 'leadId'

headerMap = {"Authorization":"555289a90fb486ea702236e516ac87b2"};
response = invokeurl
[
type :GET
headers:headerMap
];
//info response;
uservalue = response.get("users").toJSONList();
for each rec in uservalue
{
city = ifnull(rec.get("city"),"");
state = ifnull(rec.get("state"),"");
country = ifnull(rec.get("country"),"");
email = ifnull(rec.get("email"),"");
phone = ifnull(rec.get("phone"),"");
name = ifnull(rec.get("full_name"),"");
}
mp = Map();
mp.put("Owner's_City",city);
mp.put("Owner's_State",state);
mp.put("Owner's_Country",country);
mp.put("Owner's_Email",email);
mp.put("Owner's_Phone",phone);
mp.put("Owner's_Name",name);
update = zoho.crm.update("Leads",leadId.toLong(),mp);
info mp;
info update;
return "success";

Code for Version 1.0 API:

leadIdStr = input.leadId.toString();
loginemail= zoho.loginuserid ;
info userResp;
users = userResp.executeXPath("/users/user");
if ((users != null) && (users != ""))
{
userList = users.toList("-|-");
for each user in userList
{
emailNode = user.executeXPath("/user/@email");
email = emailNode.executeXPath("/email/text()");
if (email == loginemail)
{
idNode = user.executeXPath("/user/@phone");
phone = idNode.executeXPath("/phone/text()");
name = user.executeXPath("/user/text()");
email = emailNode.executeXPath("/email/text()");
}
}
}
mp=map();
mp.put("Owner's Name",name);
mp.put("Owner's Phone",phone);
mp.put("Owner's Email",email);
update=zoho.crm.updateRecord("Leads", leadIdStr, mp);
info mp;
info update;
return "success";




Note:

  • The above code can be used in conjunction with different custom functions. For example: It can be used together with the lead assignment custom function so that the record owner information is added as soon as the lead gets assigned.
  • To use this code in other modules, change the module name from "Leads" to the required module name.
  • This code adds the name, phone number and email id of the record owner in the custom field. Do create the required custom fields and try it out. The custom fields can also be added as a separate section if required.
  • To fetch other user details, do tweak the code and add the relevant custom fields. 
  • To know more about the API used in this custom function, click here.

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.

    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • Sticky Posts

                                                            • 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
                                                            • User Tips: Auto-Create Opportunity/Deal upon Quote Save (PART 1)

                                                              Problem: We use quotes which convert to sales orders but Users / Sales Reps do not create opportunities / deals and go straight to creating a quote. This leads to poor reporting. Implementing this solution improves reporting and makes it easier for users.
                                                            • Custom Function : Automatically send the Quote to the related contact

                                                              Scenario: Automatically send the Quote to the related contact.  We create Quotes for customers regularly and when we want to send the quote to the customer, we have to send it manually. We can automate this, using Custom Functions. Based on a criteria, you can trigger a workflow rule and the custom function associated to the rule and automatically send the quote to customer through an email. Please note that the quote will be sent as an inline email content and not as a PDF attachment. Please follow
                                                            • Function #50: Schedule Calls to records

                                                              Welcome back everyone! Last week's function was about changing ownership of multiple records concurrently. This week, it's going to be about scheduling calls for records in various modules. Business scenario Calls are an integral part of most sales routines.. Sales, Management, Support, all the branches of the business structure would work in cohesion only through calls. You could say they are akin to engine oil, which is required by the engine to make all of it's components function perfectly. CRM
                                                            • 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,


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator 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


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

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

                                                                                                Zoho CRM コンテンツ






                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Feature Request - Insert URL Links in Folders

                                                                                                              I would love to see the ability to create simple URL links with titles in WorkDrive. or perhaps a WorkDrive extension to allow it. Example use case: A team is working on a project and there is project folder in WordDrive. The team uses LucidChart to create
                                                                                                            • Try FSM again for our business

                                                                                                              We already have our customers individual equipment in CRM with serial numbers, install dates, warranty length and importantly next service which is generally 2 years. a month before the service date is due we get get a report and send out service reminders.
                                                                                                            • GST Slabs Redefined: Stay Compliant Using Zoho Books!

                                                                                                              Hello Everyone! The Government of India is rolling out new GST rates, a major reform aimed at simplifying the current tax structure starting 22 September 2025. GST will move from four slabs (5%, 12%, 18%, 28%) to two main slabs (5% and 18%), plus a special
                                                                                                            • Zoho CRM button to download images from image upload field

                                                                                                              Hello, I am trying to create a button in Zoho CRM that I can place in my record details view for each record and use it to download all images in the image upload fields. I tried deluge, client scripts and even with a widget, but feel lost, could not
                                                                                                            • Get Cliq Meetings in my O365 calendar

                                                                                                              Hi, we are currently evaluating to replace the Teams Messaging and Meetings with Cliq. We currently still have all our email and calendars in O365. What i want to achieve is, to create a (ZOHO) meeting from Cliq and have this meeting added to my Outlook/O365
                                                                                                            • Issue with Zoho Help Portal – Tickets Missing or Not Answered

                                                                                                              Hi, How are you? I think there may be an issue with the Zoho Help Portal. I opened a few tickets directly in the help portal a some time ago but never received any response I also opened ticket 148356451 by email. I did receive a reply to it, but the
                                                                                                            • Changing the Default Search Criteria for Finding Duplicates

                                                                                                              Hey everyone, is it possible to adjust the default search criteria for finding and merging duplicate records? Right now, CRM uses some (in my opinion nonsensical) fields as search criteria for duplicate records which do nothing except dilute the results.
                                                                                                            • Zoho Creator as LMS and Membership Solution

                                                                                                              My client is interested in using Zoho One apps to deploy their membership academy offer. Zoho Creator was an option that came up in my research: Here are the components of the program/offer: 1. Membership portal - individual login credentials for each
                                                                                                            • access to quartz for my customers

                                                                                                              Hi how can I have access to the application quartz you use for us to send you screen rocording, this feature would be immensely useful for our customers support https://quartz.zoho.com/
                                                                                                            • DUNS & Bradstreet and Credit risk monitoring integration with Zoho books

                                                                                                              Small businesses not being paid by bigger clients and clients of all sizes is a huge problem. It will be nice if Zoho develops integration with DUNS & Bradstreet(D&B) and Credit risk monitoring integration with Zoho books. That have small businesses can
                                                                                                            • Filtering Tickets based on Email headers

                                                                                                              We're starting to get a lot more junk coming into our Zoho Desk, which is then triggering unnecessary email alerts to agents. Once thing we could do to cut this junk in half, is to filter tickets based on email headers. Any email containing the `List-Unsubscribe`
                                                                                                            • Zoho Forms - Form Rules based on attachment fields

                                                                                                              Many businesses use forms to collect documents and images from customers. In many cases, you may want to trigger a notification or other automation based on whether or not an attachment was added. I've noticed that attachment fields do not appear in Rules
                                                                                                            • Add QUOTE OWNER profile image to a Quote Template

                                                                                                              I can add their email address.. phone number, DOB. I need to add a users profile picture so when they assign a template to a quote they own it adds their picture to the cover page. I've tried hacking a solution together but there has to be an easier way.
                                                                                                            • Elevate your CX delivery using CommandCenter 2.0: Simplified builder; seamless orchestration

                                                                                                              Most businesses want to create memorable customer experiences—but they often find it hard to keep them smooth, especially as they grow. To achieve a state of flow across their processes, teams often stitch together a series of automations using Workflow
                                                                                                            • New in Cadences: Option to Resume or Restart follow-ups when re-enrolling records into a Cadence, and specify custom un-enrollment criteria

                                                                                                              Managing follow-ups effectively involves understanding the appropriate timing for reaching out, as well as knowing when to take a break and resume later, or deciding if it's necessary to start the follow-up process anew. With two significant enhancements
                                                                                                            • No Response from Zoho Support in 8 Days - Typical?

                                                                                                              I have a couple of issues I'm trying to work through. Initially, I was getting support from support@zohofsm.com, but I have not received a response in 8 days (11 on another question). Is this typical? Can I pay for support? For context, I am not spamming
                                                                                                            • Office 365 and CRM mail integration: permission required

                                                                                                              Has anyone run into this weird problem? My email server is Office 365. When I try to configure Zoho CRM to use this server, a Microsoft popup window opens requesting user and password. After entering that, I get a message in the Microsoft window saying
                                                                                                            • Age Calculation

                                                                                                              I've attempted to calculate the age of someone based on their birthday input by using the formula field. It works but I don't want all those decimals on there. I then tried to use "set variable" after birthday input but I get a field type mismatch, long vs. floating. Any ideas would be wonderful.
                                                                                                            • Open filtered deals from campaign

                                                                                                              Do you think a feature like this would be feasible? Say you are seeing campaign "XYZ" in CRM. The campaign has a related list of deals. If you want to see the related deals in a deal view, you should navigate to the Deals module, open the campaign filter,
                                                                                                            • Change scheduling emails time

                                                                                                              When sending an individual email there is a great feature to schedule them to send later. I could only use the one time that is suggested. Is there a way to select another time? Regards, Glenn
                                                                                                            • Zoho CRM: how can I control which contacts to sync with Outlook?

                                                                                                              I was just playing around syncing contacts from Zoho to MS Outlook (MS365 account.) The problem is our firm has hundreds of thousands of contacts and I don't want to bury my contacts list in outlook. Any help with this is greatly appreciated.
                                                                                                            • How to overcome limitations in meetings

                                                                                                              As a company, one of our deliverables is a meeting between two other companies, where we act as facilitators. So, if we recorded this meeting  in Zoho CRM, it should be connected to 2 accounts, 2 contacts, and 1 campaign (a campaign, in our use, is the
                                                                                                            • Different MRP / Pricing for same product but different batches

                                                                                                              We often face the following situations where MRP of a particular product changes on every purchase and hence we have to charge the customer accordingly. This can't be solved by Batch tracking as of now so far as I understand Zoho. How do you manage it as of now? 
                                                                                                            • Add a 'Log a Call' link to three dot icon in Canvas

                                                                                                              Hi, There's a three dot element when creating a canvas called 'More'. I would like to modify this to add a link that says 'Log a Call' in order to quickly record the details of a cellphone call. I'd also like this to be a simple 'contact' selection and
                                                                                                            • Syncing Zoho Forms with Bigin - Embedding issue?

                                                                                                              Hello everyone, I created a Zoho Form for a page on my GoDaddy website to collect leads, which then transfers the data to Bigin. However, I'm facing an issue where it doesn't seem to work properly. I've integrated Zoho Forms with Bigin and tried embedding
                                                                                                            • Can not add fields to a Section

                                                                                                              I feel like I'm missing something obvious: I can add new Sections to my form but I can not add fields to the Sections. I've tried fields already on the form as well as dragging and dropping new fields into the Section but nothing will go into it. What
                                                                                                            • Record Logged in User while using CRM lookup field

                                                                                                              Is it possible, while using the Zoho CRM lookup field, to automatically use the user account logged into Zoho CRM in a hidden field? I was hoping to add employee accounts to my current plan. But would like a record on the Form submission of who submitted
                                                                                                            • Form Rules for Suburb Categories to alternate landing pages or Making a Fields Contents ALL CAPS

                                                                                                              I need to send differentform submissions to two to three different thank-you URLs (for Meta/Google pixels) depending on which suburb a user selects in a form. I have ~400 suburbs split into two categories (A and B, based on business value). Current challenges:
                                                                                                            • how to differentiate if whatsapp comes from certain landing page?

                                                                                                              I create a Zobot in SalesIQ to create a Whatsapp bot to capture the lead. I have 2 landing pages, one is SEO optimized and the other want is optimized for leads comes from Google Ads. I want to know from which landing page this lead came through WhatsApp
                                                                                                            • Collaps Notes

                                                                                                              There are times when long/large notes are added to a record i.e. Accounts or Deals etc. Currently, the full note is displayed in the notes related list section. It would be great if by default only 5 to 10 rows of the note are displayed when the note
                                                                                                            • Zoho Down

                                                                                                              I have a drop in my Zoho One services.
                                                                                                            • Runing RPA Agents on Headless Windows 11 Machines

                                                                                                              Has anyone tried this? Anything to be aware of regarding screen resolution?
                                                                                                            • Problem for EU users connecting Zoho CRM through Google Ads for Enhanced conversions

                                                                                                              Has anyone else experienced this problem when trying to connect Zoho CRM through Google Ads interface to setup enhanced conversions? Did you guys get it fixed somehow? The Problem: The current Google Ads integration is hardcoded to use Zoho's US authentication
                                                                                                            • Why am I getting event Pop-up Notification for events that have been cancelled?

                                                                                                              Why is Calendar Notification still popping up for events that have been cancelled or changed? Each time events are cancelled or changed, I have observed that I am still getting notifications for them. Below is a sample pop-up notification for one of the
                                                                                                            • Rich Text For Notes in Zoho CRM

                                                                                                              Hello everyone, As you know, notes are essential for recording information and ensuring smooth communication across your records. With our latest update, you can now use Rich Text formatting to organize and structure your notes more efficiently. By using
                                                                                                            • Whatsapp Limitation Questions

                                                                                                              Good day, I would like to find out about the functionality or possibility of all the below points within the Zoho/WhatsApp integration. Will WhatsApp buttons ever be possible in the future? Will WhatsApp Re-directs to different users be possible based
                                                                                                            • Issue with Inline Images in Email Reply via Zoho Desk API

                                                                                                              Hi, I am attempting to send inline images in an email reply using the Zoho Desk API, but the images are not being displayed inline for the recipient. I have followed this documentation: https://desk.zoho.com/DeskAPIDocument#Uploads https://desk.zoho.com/DeskAPIDocument#Threads#Threads_SendEmailReply
                                                                                                            • Create a draft in reply to an email via Emails API

                                                                                                              Hi, I’d like to use the outgoing webhook to automatically create a draft reply to incoming mail. How can I use the Emails API to create a draft reply that is linked to an existing email thread? I couldn’t find the relevant method in the documentation.
                                                                                                            • India Tech Support

                                                                                                              Is there no phone tech support number for India? And no chat facility either?
                                                                                                            • Billing Management: #1 Billing an Universal Business Routine

                                                                                                              Hello, As the saying goes, "Do the hardest job first", we started with the complex subject in finance, revenue management, which is considered to be the backbone for any business. Now, let's shift our focus and take a deep dive into this Billing Management
                                                                                                            • Next Page