For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

Zoho Deluge - Get Current User ID

What?
This is a quick article on different ways to get the current user ID in Zoho through code.

How?
I'm not a fan of method #1 but I only started developing in Zoho recently when API v1 was already being deprecated (end of life at the end of this year). So I'm familiar with the methods in API v2 or just using newer functions.

Method #1: API v1
copyraw
userResp = getUrl(("https://crm.zoho.com/crm/private/xml/Users/getUsers?authtoken=xxxxxxxxxxx&scope=crmapi&type=ActiveUsers"));
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 == zoho.loginuserid)
        {
            idNode = user.executeXPath("/user/@id");
            id = idNode.executeXPath("/id/text()");
        }
    }
}
  1.  userResp = getUrl(("https://crm.zoho.com/crm/private/xml/Users/getUsers?authtoken=xxxxxxxxxxx&scope=crmapi&type=ActiveUsers"))
  2.  users = userResp.executeXPath("/users/user")
  3.  if ((users != null) && (users != "")) 
  4.  { 
  5.      userList = users.toList("-|-")
  6.      for each user in userList 
  7.      { 
  8.          emailNode = user.executeXPath("/user/@email")
  9.          email = emailNode.executeXPath("/email/text()")
  10.          if (email == zoho.loginuserid) 
  11.          { 
  12.              idNode = user.executeXPath("/user/@id")
  13.              id = idNode.executeXPath("/id/text()")
  14.          } 
  15.      } 
  16.  } 

Method #2: InvokeConnector
copyraw
// get current user id
m_UserTypes = Map();
r_Response = zoho.crm.invokeConnector("crm.getusers",m_UserTypes);
l_Users = ifnull(r_Response.get("response").get("users"), {});
v_CurrentUserID=0;
for each  r_User in l_Users
{
    if(r_User.get("email")==zoho.loginuserid)
    {
        v_CurrentUserID = r_User.get("id");
    }
}
info v_CurrentUserID;
  1.  // get current user id 
  2.  m_UserTypes = Map()
  3.  r_Response = zoho.crm.invokeConnector("crm.getusers",m_UserTypes)
  4.  l_Users = ifnull(r_Response.get("response").get("users"), {})
  5.  v_CurrentUserID=0
  6.  for each  r_User in l_Users 
  7.  { 
  8.      if(r_User.get("email")==zoho.loginuserid) 
  9.      { 
  10.          v_CurrentUserID = r_User.get("id")
  11.      } 
  12.  } 
  13.  info v_CurrentUserID; 

Method #3: getRecords("users")
copyraw
// get current user id
m_UserTypes = Map();
r_Response = zoho.crm.getRecords("users");
l_Users = ifnull(r_Response.get("users"), {});
v_CurrentUserID=0;
for each  r_User in l_Users
{
    if(r_User.get("email")==zoho.loginuserid)
    {
        v_CurrentUserID = r_User.get("id");
    }
}
info v_CurrentUserID;
  1.  // get current user id 
  2.  m_UserTypes = Map()
  3.  r_Response = zoho.crm.getRecords("users")
  4.  l_Users = ifnull(r_Response.get("users"), {})
  5.  v_CurrentUserID=0
  6.  for each  r_User in l_Users 
  7.  { 
  8.      if(r_User.get("email")==zoho.loginuserid) 
  9.      { 
  10.          v_CurrentUserID = r_User.get("id")
  11.      } 
  12.  } 
  13.  info v_CurrentUserID; 
Category: Zoho :: Article: 676

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.