Zoho Deluge - InvokeConnector and useful snippets

What?
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)
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");
		}
	}
}

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");
		}
	}
}

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;

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");
		}
	}
}

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");
		}
	}
}



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.