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 Deluge: Nested Catch Statements

Zoho Deluge: Nested Catch Statements

What?
A really quick article on demonstrating a nested try...catch()... statement working in Zoho CRM.

Why?
To prove a point to ChatGPT who said this was not possible... and to deal with a scenario which exists for a client of mine.

The use-case for my Cx is that they need documents converted from HTML to PDF — as in we send it a bit of code in HTML and we want a PDF file returned. I have severaly instances of an API which accepts HTML and returns a PDF file. Nothing complex but issues with one of the servers being down, or inaccessible due to certificate expirys, means that the Cx business halts. In order to add a bit of clustering, we have added a bit of code for it to try one server first, if there is any kind of an error with that server, it tries a second server... We now want to add a third server to try if the first 2 fail for whatever reason.

How?
Admittedly, perhaps this maybe wasn't possible but as of February 2024; I have been able to test and implement this.

Consider the following code:

copyraw
try
	{
		v_Test1 = "Foo";
		info v_Test1.toLong();
	}
	catch(e)
	{
		info "Couldn't convert 'Foo' to an integer";
		try
		{
			v_Test2 = "Bar";
			info v_Test2.toLong();
			
		}
		catch(e)
		{
			info "Couldn't convert 'Bar' to an integer";
			
		}
	}
  1.  try 
  2.      { 
  3.          v_Test1 = "Foo"
  4.          info v_Test1.toLong()
  5.      } 
  6.      catch(e) 
  7.      { 
  8.          info "Couldn't convert 'Foo' to an integer"
  9.          try 
  10.          { 
  11.              v_Test2 = "Bar"
  12.              info v_Test2.toLong()
  13.   
  14.          } 
  15.          catch(e) 
  16.          { 
  17.              info "Couldn't convert 'Bar' to an integer"
  18.   
  19.          } 
  20.      } 

Pushing the product beyond it's design
Note that before anyone says I'm only try catching a doomed conversion from string to integer; I've applied this to an actual invokeURL command rather than just an info output.

copyraw
try
	{
		r_GeneratePDF = invokeurl
		[
			url: v_EndpointServer1
			type: POST
			parameters: m_Html
			headers: m_Headers1
		];
	}
	catch(e)
	{
		try
		{
			r_GeneratePDF = invokeurl
			[
				url: v_EndpointServer2
				type: POST
				parameters: m_Html
				headers: m_Headers2
			];
		}
		catch(e)
		{
			r_GeneratePDF = invokeurl
			[
				url: v_EndpointServer3
				type: POST
				parameters: m_Html
				headers: m_Headers3
			];
		}
	}
  1.  try 
  2.      { 
  3.          r_GeneratePDF = invokeUrl 
  4.          [ 
  5.              url: v_EndpointServer1 
  6.              type: POST 
  7.              parameters: m_Html 
  8.              headers: m_Headers1 
  9.          ]
  10.      } 
  11.      catch(e) 
  12.      { 
  13.          try 
  14.          { 
  15.              r_GeneratePDF = invokeUrl 
  16.              [ 
  17.                  url: v_EndpointServer2 
  18.                  type: POST 
  19.                  parameters: m_Html 
  20.                  headers: m_Headers2 
  21.              ]
  22.          } 
  23.          catch(e) 
  24.          { 
  25.              r_GeneratePDF = invokeUrl 
  26.              [ 
  27.                  url: v_EndpointServer3 
  28.                  type: POST 
  29.                  parameters: m_Html 
  30.                  headers: m_Headers3 
  31.              ]
  32.          } 
  33.      } 


This feels like really bad practice

copyraw
try
	{
		v_Test1 = "Foo";
		info v_Test1.toLong();
	}
	catch(e)
	{
		info "Couldn't convert 'Foo' to an integer";
		try
		{
			v_Test2 = "Bar";
			info v_Test2.toLong();
		}
		catch(e)
		{
			info "Couldn't convert 'Bar' to an integer";
			try
			{
				v_Test3 = "Everyday I'm Nesting...";
				info v_Test3.toLong();

			}
			catch(e)
			{
				info "Couldn't convert 'Everyday...' to an integer";
				try
				{
					v_Test4 = "Another for the road...";
					info v_Test4.toLong();

				}
				catch(e)
				{
					info "Couldn't convert 'Another...' to an integer";

				}
			}
		}
	}

// yields:
// "Couldn't convert 'Foo' to an integer" 
// "Couldn't convert 'Bar' to an integer" 
// "Couldn't convert 'Everyday...' to an integer" 
// "Couldn't convert 'Another...' to an integer"
  1.  try 
  2.      { 
  3.          v_Test1 = "Foo"
  4.          info v_Test1.toLong()
  5.      } 
  6.      catch(e) 
  7.      { 
  8.          info "Couldn't convert 'Foo' to an integer"
  9.          try 
  10.          { 
  11.              v_Test2 = "Bar"
  12.              info v_Test2.toLong()
  13.          } 
  14.          catch(e) 
  15.          { 
  16.              info "Couldn't convert 'Bar' to an integer"
  17.              try 
  18.              { 
  19.                  v_Test3 = "Everyday I'm Nesting..."
  20.                  info v_Test3.toLong()
  21.   
  22.              } 
  23.              catch(e) 
  24.              { 
  25.                  info "Couldn't convert 'Everyday...' to an integer"
  26.                  try 
  27.                  { 
  28.                      v_Test4 = "Another for the road..."
  29.                      info v_Test4.toLong()
  30.   
  31.                  } 
  32.                  catch(e) 
  33.                  { 
  34.                      info "Couldn't convert 'Another...' to an integer"
  35.   
  36.                  } 
  37.              } 
  38.          } 
  39.      } 
  40.   
  41.  // yields: 
  42.  // "Couldn't convert 'Foo' to an integer" 
  43.  // "Couldn't convert 'Bar' to an integer" 
  44.  // "Couldn't convert 'Everyday...' to an integer" 
  45.  // "Couldn't convert 'Another...' to an integer" 
Category: Zoho :: Article: 894

Add comment

Your rating:

Submit

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

Please publish modules in offcanvas position.