For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.
Zoho Deluge: Convert Map to HTML Table without a FOR loop

Zoho Deluge: Convert Map to HTML Table without a FOR loop

What?
A very quick article on converting a Map string into a HTML table without using a for each loop.

Why?
I have quite a big response from our CRM that hits a statement execution limit if I use a for loop. I have a map with 3 columns: first_name, last_name, and ID. What I want is a HTML table now with the headers and data but without using a for loop.

What I have:
copyraw
{"First_Name":"Joel","Last_Name":"Lipman","id":"1"},{"First_Name":"Another","Last_Name":"Person","id":"2"}
  1.  {"First_Name":"Joel","Last_Name":"Lipman","id":"1"},{"First_Name":"Another","Last_Name":"Person","id":"2"} 
What I want:
First NameLast NameID
JoelLipman1
AnotherPerson2

How?
This is a bit of a dirty solution and as long as "id" is not your first column (because "id" can be found in names like "David") it will work.

Assume a Map specified in deluge:
copyraw
l_Data = List();
m_Data = Map();
m_Data.put("First_Name","Joel");
m_Data.put("Last_Name","Lipman");
m_Data.put("id","1");
l_Data.add(m_Data);
m_Data = Map();
m_Data.put("First_Name","Another");
m_Data.put("Last_Name","Person");
m_Data.put("id","2");
l_Data.add(m_Data);
v_Data = l_Data.toString();
info v_Data;

// yields
// {"First_Name":"Joel","Last_Name":"Lipman","id":"1"},{"First_Name":"Another","Last_Name":"Person","id":"2"}
  1.  l_Data = List()
  2.  m_Data = Map()
  3.  m_Data.put("First_Name","Joel")
  4.  m_Data.put("Last_Name","Lipman")
  5.  m_Data.put("id","1")
  6.  l_Data.add(m_Data)
  7.  m_Data = Map()
  8.  m_Data.put("First_Name","Another")
  9.  m_Data.put("Last_Name","Person")
  10.  m_Data.put("id","2")
  11.  l_Data.add(m_Data)
  12.  v_Data = l_Data.toString()
  13.  info v_Data; 
  14.   
  15.  // yields 
  16.  // {"First_Name":"Joel","Last_Name":"Lipman","id":"1"},{"First_Name":"Another","Last_Name":"Person","id":"2"} 

Some formatting and a lot of replaceAll:
copyraw
l_Keys = List();
l_Keys = v_Data.toMap().keys();
v_DataHtml = v_Data.replaceAll("},{", "}{", true);
v_DataHtml = v_DataHtml.replaceAll(l_Keys.get(0) + "\"", "<td>", true);
v_DataHtml = v_DataHtml.replaceAll("\",\"" + l_Keys.get(1) + "\"", "<td>", true);
v_DataHtml = v_DataHtml.replaceAll("\",\"" + l_Keys.get(2) + "\"", "</td><td>", true);
// tidy up
v_DataHtml = v_DataHtml.replaceAll("{", "<tr>", true);
v_DataHtml = v_DataHtml.replaceAll("\"}", "</td></tr>\n", true);
v_DataHtml = v_DataHtml.replaceAll(":\"", "", true);
v_DataHtml = v_DataHtml.replaceAll(">\"", ">", true);
v_DataHtml = v_DataHtml.replaceAll("\"<", "<", true);
info "<table>\n" + v_DataHtml + "</table>";
  1.  l_Keys = List()
  2.  l_Keys = v_Data.toMap().keys()
  3.  v_DataHtml = v_Data.replaceAll("},{", "}{", true)
  4.  v_DataHtml = v_DataHtml.replaceAll(l_Keys.get(0) + "\"", "<td>", true)
  5.  v_DataHtml = v_DataHtml.replaceAll("\",\"" + l_Keys.get(1) + "\"", "<td>", true)
  6.  v_DataHtml = v_DataHtml.replaceAll("\",\"" + l_Keys.get(2) + "\"", "</td><td>", true)
  7.  // tidy up 
  8.  v_DataHtml = v_DataHtml.replaceAll("{", "<tr>", true)
  9.  v_DataHtml = v_DataHtml.replaceAll("\"}", "</td></tr>\n", true)
  10.  v_DataHtml = v_DataHtml.replaceAll(":\"", "", true)
  11.  v_DataHtml = v_DataHtml.replaceAll(">\"", ">", true)
  12.  v_DataHtml = v_DataHtml.replaceAll("\"<", "<", true)
  13.  info "<table>\n" + v_DataHtml + "</table>"
Category: Zoho Deluge :: Article: 276

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