Record Owner details inside a record.

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 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 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 function comes handy.

Getting started with the function:

For V1 APIs:

  1. Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
  2. Provide a name for the button. For example: "Create Quote from deal". Add a description(optional).
  3. Select the placement of the button as View page.
  4. Select the action to be performed as "Writing function".
  5. Copy the code given below.
  6. Click "Edit arguments".
  7. Enter the name as "leadId" and select the value as "Lead Id".
  8. Click Save & Execute Script.
  9. Save the changes.
  10. Select the profiles who can view this button.
  11. Click Save.

 

The Code: For V1 API - Old Editor:

leadIdStr = input.leadId.toString();
loginemail= zoho.loginuserid ;
userResp =
getUrl(("https://crm.zoho.com/crm/private/xml/Users/getUsers?authtoken=xxxxxxxxxxxxxxxxx&scope=crmapi&type=ActiveUsers")); 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";

For V2 APIs:

  1. Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
  2. Provide a name for the button. For example: "Create Quote from deal". Add a description(optional).
  3. Select the placement of the button as View page.
  4. Select the action to be performed as "Writing function".
  5. Copy the code given below.
  6. Click "Edit arguments".
  7. Enter the name as "leadId" and select the value as "Record ID".
  8. Enter the name as "ownerid" and select the value as "Record Owner ID".
  9. Click Save & Execute Script.
  10. Save the changes.
  11. Select the profiles who can view this button.
  12. Click Save.

 

The Code: For V2 API - DRE Editor:


headerMap = {"Authorization":"555289a90fb486ea702236e516ac87b2"};
response = invokeurl
[
url :"https://crm.zoho.com/crm/v2/users/" +ownerid
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";

Note:

  • The code is zoho.crm._getRecordById for Version 1.0 of.
  • Change the 'xxxxxxxxxxxxxxxxx' with your crm authtoken.
  • The above code can be used in conjunction with different functions. For example: It can be used together with the lead assignment 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.

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!

Return to Tips