So this is an article with some common snippets of code that use the InvokeConnector and do things we can't do in shortcode.
List CRM Users (ActiveUsers)
Note that this is somewhat superseded by: l_Users = zoho.crm.getRecords("users") or r_User = zoho.crm.getRecordById("users", v_UserID) but here's the old way of doing this:
l_Users= List(); m_UserType = Map(); m_UserType.put("type","ActiveUsers"); r_Response = zoho.crm.invokeConnector("crm.getusers",m_UserType); if(!isnull(r_Response.get("status_code"))) { if(r_Response.get("status_code")==200) { l_Users = r_Response.get("response").get("users"); for each v_User in l_Users { info v_User.get("full_name") + " :: " + v_User.get("id"); } } }
- l_Users= List();
- m_UserType = Map();
- m_UserType.put("type","ActiveUsers");
- r_Response = zoho.crm.invokeConnector("crm.getusers",m_UserType);
- if(!isnull(r_Response.get("status_code")))
- {
- if(r_Response.get("status_code")==200)
- {
- l_Users = r_Response.get("response").get("users");
- for each v_User in l_Users
- {
- info v_User.get("full_name") + " :: " + v_User.get("id");
- }
- }
- }
Note this can also be achieved with the following shortcode: or a specific user:
r_ZohoResponse = zoho.crm.getRecordById("users",r_DealDetails.get("Owner").get("id")); l_MatchingUsers = ifnull(r_ZohoResponse.get("users"),{}); for each r_UserDetails in l_MatchingUsers { info r_UserDetails.get("id"); }
- r_ZohoResponse = zoho.crm.getRecordById("users",r_DealDetails.get("Owner").get("id"));
- l_MatchingUsers = ifnull(r_ZohoResponse.get("users"),{});
- for each r_UserDetails in l_MatchingUsers
- {
- info r_UserDetails.get("id");
- }
List CRM Users (ActiveUsers) from Creator or other Zoho App
Note the use of .toMap() required for other apps to read this JSON string response:
l_Users= List(); m_UserType = Map(); m_UserType.put("type","ActiveUsers"); r_Response = zoho.crm.invokeConnector("crm.getusers",m_UserType); if(!isnull(r_Response.toMap().get("status_code"))) { if(r_Response.toMap().get("status_code")==200) { l_Users = r_Response.toMap().get("response").toMap().get("users"); for each v_User in l_Users { info v_User.get("full_name") + " :: " + v_User.get("email"); } } }
- l_Users= List();
- m_UserType = Map();
- m_UserType.put("type","ActiveUsers");
- r_Response = zoho.crm.invokeConnector("crm.getusers",m_UserType);
- if(!isnull(r_Response.toMap().get("status_code")))
- {
- if(r_Response.toMap().get("status_code")==200)
- {
- l_Users = r_Response.toMap().get("response").toMap().get("users");
- for each v_User in l_Users
- {
- info v_User.get("full_name") + " :: " + v_User.get("email");
- }
- }
- }
Delete a CRM Record
m_Delete = Map(); m_Delete.put("module","Leads"); m_Delete.put("id","0123456789012345678"); r_Delete = zoho.crm.invokeConnector("crm.delete", m_Delete); info r_Delete;
- m_Delete = Map();
- m_Delete.put("module","Leads");
- m_Delete.put("id","0123456789012345678");
- r_Delete = zoho.crm.invokeConnector("crm.delete", m_Delete);
- info r_Delete;
Get Organization Details
m_OrgDetails = Map(); r_Response = zoho.crm.invokeConnector("crm.getorg", m_OrgDetails); if(!isnull(r_Response.get("status_code"))) { if(r_Response.get("status_code")==200) { l_OrgDetails = r_Response.get("response").get("org"); for each r_Org in l_OrgDetails { info r_Org.get("company_name") + " :: " + r_Org.get("id"); } } }
- m_OrgDetails = Map();
- r_Response = zoho.crm.invokeConnector("crm.getorg", m_OrgDetails);
- if(!isnull(r_Response.get("status_code")))
- {
- if(r_Response.get("status_code")==200)
- {
- l_OrgDetails = r_Response.get("response").get("org");
- for each r_Org in l_OrgDetails
- {
- info r_Org.get("company_name") + " :: " + r_Org.get("id");
- }
- }
- }
Get Module MetaData
m_Module = Map(); m_Module.put("module","Leads"); // omit this line to get metadata for all modules r_Module = zoho.crm.invokeConnector("crm.modulemetadata", m_Module); if(!isnull(r_Module.get("status_code"))) { if(r_Module.get("status_code")==200) { l_ModuleMeta = r_Module.get("response").get("modules"); for each v_ModuleMeta in l_ModuleMeta { info v_ModuleMeta.get("api_name") + " :: " + v_ModuleMeta.get("id"); } } }
- m_Module = Map();
- m_Module.put("module","Leads"); // omit this line to get metadata for all modules
- r_Module = zoho.crm.invokeConnector("crm.modulemetadata", m_Module);
- if(!isnull(r_Module.get("status_code")))
- {
- if(r_Module.get("status_code")==200)
- {
- l_ModuleMeta = r_Module.get("response").get("modules");
- for each v_ModuleMeta in l_ModuleMeta
- {
- info v_ModuleMeta.get("api_name") + " :: " + v_ModuleMeta.get("id");
- }
- }
- }