Get User Data

Get User Data

The details about the users of an extension or vertical solution can be fetched using the invokeConnector() deluge task.

Syntax

<Response> = zoho.crm.invokeConnector("crm.getusers", <userTypeMap map>);

where,
<Response> is the task response returned as a Map.
<userTypeMap> is a map variable that can be used to specify the user Type. You can fetch All Users, Admin Users, Active Users, and Inactive Users using the key, value pairs ("type","AllUsers"), ("type","AdminUsers"), ("type","ActiveUsers"), and ("type","DeactivateUsers") respectively.

 Example

Fetch all the active users associated with an extension or vertical solution.

userTypeMap = Map();
userTypeMap.put("type","ActiveUsers");
response = zoho.crm.invokeConnector("crm.getusers",userTypeMap);
info response;

Note

If in the above script, an empty map is passed for the variable userTypeMap, then all users will be fetched.
userTypeMap = Map();
response = zoho.crm.invokeConnector("crm.getusers",userTypeMap);

Response Format

{"status_code":200,"response":"{\"users\":[{\"country\":null,\"role\":{\"name\":\"CEO\",
\"id\":\"3388926000000026005\"},\"city\":null,\"language\":\"en_US\",\"locale\":\"en_US\",
\"microsoft\":false,\"Modified_By\":{\"name\":\"ZohoDemo \",\"id\":\"3388926000000166021\"},
\"street\":null,\"alias\":null,\"id\":\"3388926000000318001\",\"state\":null,\"fax\":null,
\"country_locale\":\"US\",\"first_name\":\"Sam\",\"email\":\"sam.j@zohocorp.com\",
\"Reporting_To\":null,\"zip\":null,\"created_time\":\"2018-10-25T15:21:04+05:30\",
\"Modified_Time\":\"2018-10-25T15:21:04+05:30\",\"website\":null,\"time_format\":\"hh:mm a\",
\"offset\":19800000,\"profile\":{\"name\":\"Administrator\",\"id\":\"3388926000000026011\"},
\"mobile\":\"9980065632\",\"last_name\":\"James\",\"time_zone\":\"IST\",\"created_by\":
{\"name\":\"ZohoTest \",\"id\":\"3388926000000166021\"},\"zuid\":\"650456410\",
\"confirm\":true,\"full_name\":\"Sam James\",\"territories\":[],\"phone\":null,\"dob\":null,
\"date_format\":\"MM/dd/yyyy\",\"status\":\"active\"},{\"country\":null,\"role\":{\"name\":\"CEO\",
\"id\":\"3388926000000026005\"},\"customize_info\":{\"notes_desc\":null,
\"show_right_panel\":null,\"bc_view\":null,\"show_home\":false,\"show_detail_view\":true,
\"unpin_recent_item\":null},\"city\":null,\"signature\":null,\"name_format\":
\"Salutation,First Name,Last Name\",\"language\":\"en_US\",\"locale\":\"en_US\",
\"microsoft\":false,\"personal_account\":true,\"default_tab_group\":\"0\",
\"Modified_By\":{\"name\":\"ZohoDemo \",\"id\":\"3388926000000166021\"},
\"street\":null,\"alias\":null,\"theme\":{\"normal_tab\":{\"font_color\":\"#FFFFFF\",
\"background\":\"#222222\"},\"selected_tab\":{\"font_color\":\"#FFFFFF\",
\"background\":\"#222222\"},\"new_background\":null,\"background\":\"#F3F0EB\",
\"screen\":\"fixed\",\"type\":\"default\"},\"id\":\"3388926000000166021\",\"state\":null,
\"fax\":null,\"country_locale\":\"US\",\"first_name\":\"Elsa\",\"email\":\"elsa.g+m40@zohocorp.com\",
\"Reporting_To\":null,\"zip\":null,\"decimal_separator\":\"en_US\",\"created_time\":
\"2018-07-19T18:19:26+05:30\",\"Modified_Time\":\"2018-07-19T18:19:26+05:30\",\"website\":null,
\"time_format\":\"hh:mm a\",\"offset\":19800000,\"profile\":{\"name\":\"Administrator\",
\"id\":\"3388926000000026011\"},\"mobile\":null,\"last_name\":null,\"time_zone\":\"Asia/Kolkata\",
\"created_by\":{\"name\":\"ZohoTest\",\"id\":\"3388926000000166021\"},\"zuid\":\"671500082\",
\"confirm\":true,\"full_name\":\"elsa \",\"territories\":[],\"phone\":null,\"dob\":null,
\"date_format\":\"MM/dd/yyyy\",\"status\":\"active\"}],\"info\":{\"per_page\":200,\"count\":2,
\"page\":1,\"more_records\":false}}"}

Additional Example

Round Robin Assignment

Assign Leads to your users using the round robin method.

lead_id = input.lead.get("Leads.ID");
datamap = map();
datamap.put("module", "Leads");
datamap.put("id", lead_id);
resp = zoho.crm.invokeConnector(("crm.get"), datamap);
resp1 = (resp.get("response")).toMap();
datalist = resp1.get("data").toJSONList();
reqq = datalist.get(0).toMap();
l_number = (reqq.get(("roundrobinleadassignment0.Lead_Number"))).toLong();
rule = reqq.get(("roundrobinleadassignment0.Assign_Using_Active_Assignment_Rule"));
m = map();
resp = zoho.crm.invokeConnector(("crm.getusers"), m);
respMap = (resp.get("response")).toMap();
users = respMap.get("users");
userList = users.toJSONList();
userIds = List();
for each user in userList
{
     eachUser = user.toMap();
     userIds.add(eachUser.get("id"));
}
max_lead_level = (userIds.size()).toLong();
ans = (abs((l_number % max_lead_level))).toLong();
if (rule == "true")
{
     ownerid = userIds.get(ans);
     updateMap = Map();
     updateMap.put("Lead_Owner" : ownerid);
     resp = zoho.crm.update("Leads",lead_id,updateMap);
}

Response

{"status_code":200,"response":"{"users":[{"zip":6000049,"phone":9876543210,"fax":null,
"status":"active","website":"http://www.zoho.com","street":null,"state":"Tamil Nadu",
"country":"in","city":"Chennai","alias_name":null,"first_name":"Zoho","timezone":"Asia/Calcutta",
"zuid":"3032021", "email":"platform+demo@zohocorp.com ","dob":22.2.1993,"last_name":Demo,
"time_format":null, "role":"CEO","user_id":"1297376000000094003","language":"en_US",
"confirm":true,"mobile":"9500080429","full_name":"Zoho Demo ","profile":"Administrator"},
{"zip":null,"phone":null,"fax":null,"status":"deleted","website":null,"street":null,
"state":null,"country":null,"city":null, "alias_name":null,"first_name":"Zoho1",
"timezone":"Asia/Kolkata","zuid":null,"email":"platform+demo1@zohocorp.com ",
"dob":null,"last_name":"Demo1","time_format":null,"role":"CEO","user_id":"1297376000000108007",
"language":"en","confirm":true,"mobile":null,"full_name":"Zoho1 Demo1","profile":"Administrator"}]}"}

 Related Links

https://www.zoho.com/crm/help/api/v2/#Users-APIs

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeveloper.com