For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.

Zoho Analytics & Zoho People: Monitor DataSource Sync

What?
A quick article on how to setup an automation that checks if a datasource synchronization between Zoho People and Zoho Analytics failed. This can be adapted to any data source for Zoho Analytics.

Why?
We're assisting a client implement Zoho People as their new HR solution. Zoho Analytics is used to generate specific spreadsheets for a feed into their third-party payroll system. If the data is incorrect in Zoho Analytics, and payroll gets run with these discrepancies, then they will have a fair few disgruntled employees who may have been paid incorrectly. As such this system has to be reliable and the system managers need to be notified in advance of any errors with the intention to be able to correct any inconsistencies themselves.

How?
We're going to add a scheduled workflow on a daily basis at 1am in the morning every day. This will be added to the client's Zoho People instance which will check the datasource metadata via the Analytics API.

Add a custom scheduler in Zoho People
  1. Login to ZohoPeople as a system administrator
  2. Click on the cog icon in the top right to go to the setup screen.
  3. Under "Automation", click on "Scheduler"
  4. Click on the "Add Scheduler" button
  5. Complete the "Scheduler" header information such as the name, description, start date/time, frequency, and timezone.
  6. While you're here, click on "Connections" at the top of the IDE (where you paste the code) and ensure you setup a Connection that does NOT use the credentials of the logged-in user and has as scope ZohoAnalytics.metadata.read.

The code
copyraw
/* *******************************************************************************
Function:       void Check_DataSources_Sync_to_ZohoAnalytics ()
Label:          Check DataSources Sync to ZohoAnalytics
Trigger:        Scheduled daily at 1am starting from tomorrow (3-Jul-2024)
Purpose:		To warn system managers if a sync started failing.
Inputs:         None
Outputs:        Emails system manager if any failures.

Date Created:   2024-07-02 (JoelLipman.com - Joel Lipman)
                - Initial release
Date Modified:	???
                - ???

More Information:
                https://www.zoho.com/analytics/api/v2/metadata-api/datasources.html

******************************************************************************* */
//
// initialize
v_LastSyncTime = null;
v_LastSyncStatus = "?";
m_DataSourceInfo = Map();
//
// read the TLD (eu or com or com.in) from the URL when logged into Zoho Analytics
v_BaseURL = "https://analyticsapi.zoho.com";
//
// to get workspace ID, look at the URL in ZohoAnalytics and take the number straight after the word "workspace/"
v_WorkspaceID = "12345000001234567";
//
// to get the Analytics Org ID, login to Zoho Analytics, ensuring you are on the "Home" page (click on "Home" in top menu if not),
// then click on the cog icon "Organization Settings", then click on "Organization Details",
// then look at the URL (website address) and take the number directly after "org-details/"
v_AnalyticsOrgID = "20240702123";
//
// generate request header
m_Header = Map();
m_Header.put("ZANALYTICS-ORGID",v_AnalyticsOrgID);
//
// generate the endpoint to read the analytics metadata on the syncs
v_Endpoint = v_BaseURL + "/restapi/v2/workspaces/" + v_WorkspaceID + "/datasources";
//
// send the request
r_Analytics = invokeurl
[
	url :v_Endpoint
	type :GET
	headers:m_Header
	connection:"my_connection"
];
//info r_Analytics;
//
// parse response
if(r_Analytics.get("status") == "success")
{
	m_ResponseData = ifnull(r_Analytics.get("data"),Map());
	l_DataSources = ifnull(m_ResponseData.get("dataSources"),List());
	for each  m_DataSource in l_DataSources
	{
		if(m_DataSource.get("datasourceName").equalsIgnoreCase("Zoho People"))
		{
			v_LastSyncTime = m_DataSource.get("lastDataSyncTime");
			v_LastSyncStatus = m_DataSource.get("lastDataSyncStatus");
			m_DataSourceInfo = m_DataSource;
			break;
		}
	}
}
//info m_DataSourceInfo;
//
// to email or not to email, that is the question, whether 'tis nobler in the mind to suffer...
if(!v_LastSyncStatus.equalsIgnoreCase("Data Sync Successful"))
{
	v_To = "Client <my_client@their_company.com>";
	v_Cc = {"Joel Lipman Support Desk <This email address is being protected from spambots. You need JavaScript enabled to view it.>"};
	v_Subject = "URGENT: Sync Between Zoho People and Zoho Analytics Failed!!!";
	v_Message = "Hi there!<br /><br />This is an email to advise that the synchronization between your Zoho People and Zoho Analytics instances failed.  The last synchronization data we have is as follows:<br /><br /><table style='margin:0 auto;'>";
	if(!isNull(m_DataSourceInfo.get("datasourceName")))
	{
		for each  v_DataSourceKey in m_DataSourceInfo.keys()
		{
			v_Message = v_Message + "<tr><td>" + v_DataSourceKey + "</td><td>" + ifnull(m_DataSourceInfo.get(v_DataSourceKey),"?") + "</td></tr>";
		}
	}
	else
	{
		v_Message = v_Message + "<tr><td><b>No Datasource Information!</b> Either the data source synchronization has been switched off or there is an error with a connection account between Zoho People and Zoho Analytics.</td></tr>";
	}
	v_Message = v_Message + "</table><br />This may have been a one-off blip but if you get this error again tomorrow, you should raise this with either Zoho or your Zoho partner.  This email will also have been copied to the ticket support system of your Zoho Partner.<br /><br />Kind Regards,<br /><br /><b>the Joel Lipman team</b><br /><a href='mailto:This email address is being protected from spambots. You need JavaScript enabled to view it.'>This email address is being protected from spambots. You need JavaScript enabled to view it.</a><br /><a href='https://joellipman.com'>www.joellipman.com</a>";
	sendmail
	[
		from :zoho.adminuserid
		to :v_To
		cc:v_Cc
		subject :v_Subject
		message :v_Message
	]
}
  1.  /* ******************************************************************************* 
  2.  Function:       void Check_DataSources_Sync_to_ZohoAnalytics () 
  3.  Label:          Check DataSources Sync to ZohoAnalytics 
  4.  Trigger:        Scheduled daily at 1am starting from tomorrow (3-Jul-2024) 
  5.  Purpose:        To warn system managers if a sync started failing. 
  6.  Inputs:         None 
  7.  Outputs:        Emails system manager if any failures. 
  8.   
  9.  Date Created:   2024-07-02 (JoelLipman.com - Joel Lipman) 
  10.                  - Initial release 
  11.  Date Modified:    ??? 
  12.                  - ??? 
  13.   
  14.  More Information: 
  15.                  https://www.zoho.com/analytics/api/v2/metadata-api/datasources.html 
  16.   
  17.  ******************************************************************************* */ 
  18.  // 
  19.  // initialize 
  20.  v_LastSyncTime = null
  21.  v_LastSyncStatus = "?"
  22.  m_DataSourceInfo = Map()
  23.  // 
  24.  // read the TLD (eu or com or com.in) from the URL when logged into Zoho Analytics 
  25.  v_BaseURL = "https://analyticsapi.zoho.com"
  26.  // 
  27.  // to get workspace ID, look at the URL in ZohoAnalytics and take the number straight after the word "workspace/" 
  28.  v_WorkspaceID = "12345000001234567"
  29.  // 
  30.  // to get the Analytics Org ID, login to Zoho Analytics, ensuring you are on the "Home" page (click on "Home" in top menu if not), 
  31.  // then click on the cog icon "Organization Settings", then click on "Organization Details", 
  32.  // then look at the URL (website address) and take the number directly after "org-details/" 
  33.  v_AnalyticsOrgID = "20240702123"
  34.  // 
  35.  // generate request header 
  36.  m_Header = Map()
  37.  m_Header.put("ZANALYTICS-ORGID",v_AnalyticsOrgID)
  38.  // 
  39.  // generate the endpoint to read the analytics metadata on the syncs 
  40.  v_Endpoint = v_BaseURL + "/restapi/v2/workspaces/" + v_WorkspaceID + "/datasources"
  41.  // 
  42.  // send the request 
  43.  r_Analytics = invokeUrl 
  44.  [ 
  45.      url :v_Endpoint 
  46.      type :GET 
  47.      headers:m_Header 
  48.      connection:"my_connection" 
  49.  ]
  50.  //info r_Analytics; 
  51.  // 
  52.  // parse response 
  53.  if(r_Analytics.get("status") == "success") 
  54.  { 
  55.      m_ResponseData = ifnull(r_Analytics.get("data"),Map())
  56.      l_DataSources = ifnull(m_ResponseData.get("dataSources"),List())
  57.      for each  m_DataSource in l_DataSources 
  58.      { 
  59.          if(m_DataSource.get("datasourceName").equalsIgnoreCase("Zoho People")) 
  60.          { 
  61.              v_LastSyncTime = m_DataSource.get("lastDataSyncTime")
  62.              v_LastSyncStatus = m_DataSource.get("lastDataSyncStatus")
  63.              m_DataSourceInfo = m_DataSource; 
  64.              break
  65.          } 
  66.      } 
  67.  } 
  68.  //info m_DataSourceInfo; 
  69.  // 
  70.  // to email or not to email, that is the question, whether 'tis nobler in the mind to suffer... 
  71.  if(!v_LastSyncStatus.equalsIgnoreCase("Data Sync Successful")) 
  72.  { 
  73.      v_To = "Client <my_client@their_company.com>"
  74.      v_Cc = {"Joel Lipman Support Desk <This email address is being protected from spambots. You need JavaScript enabled to view it.>"}
  75.      v_Subject = "URGENT: Sync Between Zoho People and Zoho Analytics Failed!!!"
  76.      v_Message = "Hi there!<br /><br />This is an email to advise that the synchronization between your Zoho People and Zoho Analytics instances failed.  The last synchronization data we have is as follows:<br /><br /><table style='margin:0 auto;'>"
  77.      if(!isNull(m_DataSourceInfo.get("datasourceName"))) 
  78.      { 
  79.          for each  v_DataSourceKey in m_DataSourceInfo.keys() 
  80.          { 
  81.              v_Message = v_Message + "<tr><td>" + v_DataSourceKey + "</td><td>" + ifnull(m_DataSourceInfo.get(v_DataSourceKey),"?") + "</td></tr>"
  82.          } 
  83.      } 
  84.      else 
  85.      { 
  86.          v_Message = v_Message + "<tr><td><b>No Datasource Information!</b> Either the data source synchronization has been switched off or there is an error with a connection account between Zoho People and Zoho Analytics.</td></tr>"
  87.      } 
  88.      v_Message = v_Message + "</table><br />This may have been a one-off blip but if you get this error again tomorrow, you should raise this with either Zoho or your Zoho partner.  This email will also have been copied to the ticket support system of your Zoho Partner.<br /><br />Kind Regards,<br /><br /><b>the Joel Lipman team</b><br /><a href='mailto:This email address is being protected from spambots. You need JavaScript enabled to view it.'>This email address is being protected from spambots. You need JavaScript enabled to view it.</a><br /><a href='https://joellipman.com'>www.joellipman.com</a>"
  89.      sendmail 
  90.      [ 
  91.          from :zoho.adminuserid 
  92.          to :v_To 
  93.          cc:v_Cc 
  94.          subject :v_Subject 
  95.          message :v_Message 
  96.      ] 
  97.  } 


Category: Zoho :: Article: 876

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

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 bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2025 Joel Lipman .com. All Rights Reserved.