For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

Zoho CRM & Zoho Books: Custom Related Lists Deluge

What?
This is an article to quickly demo a couple of snippets of code to display values in a custom related list as well as to display empty custom related lists.

Why?
Because I keep forgetting how to do this and it takes about an hour to go through the documentation and get a working solution.

How?
So the article below shows how to do this Zoho CRM and how to do it in Zoho Books...

The example below is that we are going to search for some records in Zoho Creator and display these in either Zoho Books or Zoho CRM. For demonstration purposes, these have been simplified and will need to be adapted for your needs. Note that I have used 2 URL methods of linking to the Creator app and some data formatting that I tend to use regularly for my benefit later on when I simply copy & paste the below code templates.

Zoho CRM
copyraw
//
// search in Creator
v_OwnerName = <AppOwner>;
v_AppLinkName = <AppName>;
v_FormLinkName = <FormName>;
v_ViewLinkName = <ReportName>;
v_Condition = "(Opportunities==\"" + v_DealID + "\")&&(UpdateClick==\"Yes\")";
r_SearchResults = zoho.creator.getRecords(v_OwnerName,v_AppLinkName,v_ViewLinkName,v_Condition,1,100,"joels_connection");
v_ResponseCode = ifnull(r_SearchResults.get("code"),500).toLong();
//
// if found records
if(v_ResponseCode == 3000)
{
	v_RelatedListXML = "<record>";
	l_SearchResults = r_SearchResults.get("data").toJSONList();
	for each  r_Result in l_SearchResults
	{
		// init
		v_DateTill= "-";
		v_QuoteTotalDisp= "-";
		v_Index = v_Index + 1;
		v_RelatedListXML = v_RelatedListXML + "<row no=\"" + v_Index + "\">";
		//
		// retrieve
		v_CreatorQuoteID = r_Result.get("ID");
		v_LinkUrl2 = "https://creatorapp.zoho.eu/" + v_OwnerName + "/" + v_AppLinkName + "/#Page:OpenQuote?ID=" + v_CreatorQuoteID;
		v_QuoteRef = ifnull(r_Result.get("Quote_Ref"),"-");
		v_QuoteName = ifnull(r_Result.get("Quote_Name"),"-");
		v_QuoteStage = ifnull(r_Result.get("Quote_Stage"),"-");
		v_QuoteCurr = ifnull(r_Result.get("Quote_Currency"),"GBP");
		v_QuoteTotal = ifnull(r_Result.get("Total_Amount"),0.0).toDecimal();
		v_ExchangeRate = ifnull(r_Result.get("Exchange_Rate"),1);
		v_ModifiedTime = ifnull(r_Result.get("Modified_Time"),r_Result.get("Added_Time")).toTime().toString("dd/MM/yyyy hh:mm a");
		//
		// future proofs
		v_ExchangeRate = if(v_ExchangeRate == 0,1,v_ExchangeRate);
		// 
		// transforms
		if(r_Result.get("Valid_Till") != null)
		{
			v_DateTill = r_Result.get("Valid_Until").toDate().toString("dd/MM/yyyy");
		}
		if(v_QuoteTotal != 0)
		{
			v_QuoteTotalGBP = (v_QuoteTotal.toDecimal() / v_ExchangeRate).toDecimal().round(2);
			//
			// format currency with commas (thousand separator) and 2 decimals
			v_QuoteTotalStr = v_QuoteTotal.toDecimal().round(2).toString().replaceAll("(?<!\.\d)(?<=\d)(?=(?:\d\d\d)+\b)",",");
			v_QuoteTotalGBPStr = v_QuoteTotalGBP.toDecimal().round(2).toString().replaceAll("(?<!\.\d)(?<=\d)(?=(?:\d\d\d)+\b)",",");
			//
			// to display both side by side if different otherwise display GBP
			if(!isnull(m_Currencies.get(v_QuoteCurr)))
			{
				if(v_QuoteCurr == "GBP")
				{
					v_QuoteTotalDisp = m_Currencies.get(v_QuoteCurr) + " " + v_QuoteTotalGBPStr;
				}
				else
				{
					v_QuoteTotalDisp = m_Currencies.get(v_QuoteCurr) + " " + v_QuoteTotalStr + " (£ " + v_QuoteTotalGBPStr + ")";
				}
			}
			else
			{
				v_QuoteTotalDisp = v_QuoteTotalStr + " " + v_QuoteCurr + " (£ " + v_QuoteTotalGBPStr + ")";
			}
		}
		v_RelatedListXML = v_RelatedListXML + "<FL val=\"Quote Ref\">" + v_QuoteRef + "</FL>";
		// don't forget to escape quote name with CDATA in case of XML banned characters
		v_RelatedListXML = v_RelatedListXML + "<FL val=\"Quote Name\" link=\"true\" url=\"" + v_LinkUrl2 + "\"><![CDATA[" + v_QuoteName + "]]></FL>";
		v_RelatedListXML = v_RelatedListXML + "<FL val=\"Valid Till\">" + v_DateTill + "</FL>";
		v_RelatedListXML = v_RelatedListXML + "<FL val=\"Stage\">" + v_QuoteStage + "</FL>";
		v_RelatedListXML = v_RelatedListXML + "<FL val=\"Total Amount\">" + v_QuoteTotalDisp + "</FL>";
		v_RelatedListXML = v_RelatedListXML + "<FL val=\"Modified Time\">" + v_ModifiedTime + "</FL>";
		v_RelatedListXML = v_RelatedListXML + "</row>";
		v_Index = v_Index + 1;
	}
	v_RelatedListXML = v_RelatedListXML + "</record>";
}
else
{
	// display "no records found"
	v_RelatedListXML = "<error><message>";
	v_RelatedListXML = v_RelatedListXML + "No records found";
	v_RelatedListXML = v_RelatedListXML + "</message></error>";
}
//
// output
return v_RelatedListXML;
  1.  // 
  2.  // search in Creator 
  3.  v_OwnerName = <AppOwner>
  4.  v_AppLinkName = <AppName>
  5.  v_FormLinkName = <FormName>
  6.  v_ViewLinkName = <ReportName>
  7.  v_Condition = "(Opportunities==\"" + v_DealID + "\")&&(UpdateClick==\"Yes\")"
  8.  r_SearchResults = zoho.creator.getRecords(v_OwnerName,v_AppLinkName,v_ViewLinkName,v_Condition,1,100,"joels_connection")
  9.  v_ResponseCode = ifnull(r_SearchResults.get("code"),500).toLong()
  10.  // 
  11.  // if found records 
  12.  if(v_ResponseCode == 3000) 
  13.  { 
  14.      v_RelatedListXML = "<record>"
  15.      l_SearchResults = r_SearchResults.get("data").toJSONList()
  16.      for each  r_Result in l_SearchResults 
  17.      { 
  18.          // init 
  19.          v_DateTill= "-"
  20.          v_QuoteTotalDisp= "-"
  21.          v_Index = v_Index + 1
  22.          v_RelatedListXML = v_RelatedListXML + "<row no=\"" + v_Index + "\">"
  23.          // 
  24.          // retrieve 
  25.          v_CreatorQuoteID = r_Result.get("ID")
  26.          v_LinkUrl2 = "https://creatorapp.zoho.eu/" + v_OwnerName + "/" + v_AppLinkName + "/#Page:OpenQuote?ID=" + v_CreatorQuoteID; 
  27.          v_QuoteRef = ifnull(r_Result.get("Quote_Ref"),"-")
  28.          v_QuoteName = ifnull(r_Result.get("Quote_Name"),"-")
  29.          v_QuoteStage = ifnull(r_Result.get("Quote_Stage"),"-")
  30.          v_QuoteCurr = ifnull(r_Result.get("Quote_Currency"),"GBP")
  31.          v_QuoteTotal = ifnull(r_Result.get("Total_Amount"),0.0).toDecimal()
  32.          v_ExchangeRate = ifnull(r_Result.get("Exchange_Rate"),1)
  33.          v_ModifiedTime = ifnull(r_Result.get("Modified_Time"),r_Result.get("Added_Time")).toTime().toString("dd/MM/yyyy hh:mm a")
  34.          // 
  35.          // future proofs 
  36.          v_ExchangeRate = if(v_ExchangeRate == 0,1,v_ExchangeRate)
  37.          // 
  38.          // transforms 
  39.          if(r_Result.get("Valid_Till") != null) 
  40.          { 
  41.              v_DateTill = r_Result.get("Valid_Until").toDate().toString("dd/MM/yyyy")
  42.          } 
  43.          if(v_QuoteTotal != 0) 
  44.          { 
  45.              v_QuoteTotalGBP = (v_QuoteTotal.toDecimal() / v_ExchangeRate).toDecimal().round(2)
  46.              // 
  47.              // format currency with commas (thousand separator) and 2 decimals 
  48.              v_QuoteTotalStr = v_QuoteTotal.toDecimal().round(2).toString().replaceAll("(?<!\.\d)(?<=\d)(?=(?:\d\d\d)+\b)",",")
  49.              v_QuoteTotalGBPStr = v_QuoteTotalGBP.toDecimal().round(2).toString().replaceAll("(?<!\.\d)(?<=\d)(?=(?:\d\d\d)+\b)",",")
  50.              // 
  51.              // to display both side by side if different otherwise display GBP 
  52.              if(!isnull(m_Currencies.get(v_QuoteCurr))) 
  53.              { 
  54.                  if(v_QuoteCurr == "GBP") 
  55.                  { 
  56.                      v_QuoteTotalDisp = m_Currencies.get(v_QuoteCurr) + " " + v_QuoteTotalGBPStr; 
  57.                  } 
  58.                  else 
  59.                  { 
  60.                      v_QuoteTotalDisp = m_Currencies.get(v_QuoteCurr) + " " + v_QuoteTotalStr + (£ " + v_QuoteTotalGBPStr + ")"
  61.                  } 
  62.              } 
  63.              else 
  64.              { 
  65.                  v_QuoteTotalDisp = v_QuoteTotalStr + " " + v_QuoteCurr + (£ " + v_QuoteTotalGBPStr + ")"
  66.              } 
  67.          } 
  68.          v_RelatedListXML = v_RelatedListXML + "<FL val=\"Quote Ref\">" + v_QuoteRef + "</FL>"
  69.          // don't forget to escape quote name with CDATA in case of XML banned characters 
  70.          v_RelatedListXML = v_RelatedListXML + "<FL val=\"Quote Name\" link=\"true\" url=\"" + v_LinkUrl2 + "\"><![CDATA[" + v_QuoteName + "]]></FL>"
  71.          v_RelatedListXML = v_RelatedListXML + "<FL val=\"Valid Till\">" + v_DateTill + "</FL>"
  72.          v_RelatedListXML = v_RelatedListXML + "<FL val=\"Stage\">" + v_QuoteStage + "</FL>"
  73.          v_RelatedListXML = v_RelatedListXML + "<FL val=\"Total Amount\">" + v_QuoteTotalDisp + "</FL>"
  74.          v_RelatedListXML = v_RelatedListXML + "<FL val=\"Modified Time\">" + v_ModifiedTime + "</FL>"
  75.          v_RelatedListXML = v_RelatedListXML + "</row>"
  76.          v_Index = v_Index + 1
  77.      } 
  78.      v_RelatedListXML = v_RelatedListXML + "</record>"
  79.  } 
  80.  else 
  81.  { 
  82.      // display "no records found" 
  83.      v_RelatedListXML = "<error><message>"
  84.      v_RelatedListXML = v_RelatedListXML + "No records found"
  85.      v_RelatedListXML = v_RelatedListXML + "</message></error>"
  86.  } 
  87.  // 
  88.  // output 
  89.  return v_RelatedListXML; 

in Zoho Books
copyraw
//
// find all related quotes
l_DataRows = List();
v_QuoteRefID = "0";
v_CrmOppID = "0";
v_OwnerName = <AppOwner>;
v_AppLinkName = <AppName>;
v_FormLinkName = <FormName>;
v_ViewLinkName = <ReportName>;
if(!isnull(salesorder.get("salesorder_id")))
{
	v_CreatorSoID = salesorder.get("salesorder_id");
}
v_SearchCriteria = "Sales_Order_ID==\"" + v_CreatorSoID + "\"";
r_SearchResults = zoho.creator.getRecords(v_OwnerName,v_AppLinkName,v_ViewLinkName,v_SearchCriteria,1,100,"joels_connnection");
v_ResponseCode = ifnull(r_SearchResults.get("code"),500).toLong();
if(v_ResponseCode == 3000)
{
	l_HeaderColumns = List();
	l_HeaderColumns.add({"key":"quote_name","value":"Name"});
	l_HeaderColumns.add({"key":"valid_till","value":"Valid Till"});
	l_HeaderColumns.add({"key":"quote_status","value":"Quote Status"});
	l_SearchResults = r_SearchResults.get("data").toJSONList();
	for each  r_Result in l_SearchResults
	{
		v_CreatorQuoteID = r_Result.get("ID");
		m_DataRow = Map();
		m_LinkedValue = Map();
		m_LinkedValue.put("value",r_Result.get("Quote_Name"));
		m_LinkedValue.put("isExternal",true);
		m_LinkedValue.put("link","https://app.zohocreator.eu/"+v_OwnerName+"/"+v_AppLinkName+"/"+v_FormLinkName+"/record-edit/"+v_ViewLinkName+"/"+v_CreatorQuoteID+"?param1=my_param_value");
		v_DateTill = "-";
		if(!isnull(r_Result.get("Valid_Till")))
		{
			v_DateTill = r_Result.get("Valid_Till").toDate().toString("dd/MM/yyyy");
		}
		m_DataRow.put("quote_name",m_LinkedValue);
		m_DataRow.put("valid_till",v_DateTill);
		m_DataRow.put("quote_status",r_Result.get("Quote_Status"));
		l_DataRows.add(m_DataRow);
	}
}
else
{
	l_HeaderColumns = List();
	l_HeaderColumns.add({"key":"message","value":"Message"});
	//
	if(v_ResponseCode == 3100)
	{
		m_DataRow = Map();
		m_DataRow.put("message","No records found");
		l_DataRows.add(m_DataRow);
	}
	else
	{
		m_DataRow = Map();
		m_DataRow.put("message",r_SearchResults.get("message") + " :: " + v_ResponseCode);
		l_DataRows.add(m_DataRow);
	}
}
//
m_RelatedList = Map();
m_RelatedList.put("header_context",l_HeaderColumns);
m_RelatedList.put("data",l_DataRows);
return m_RelatedList;
  1.  // 
  2.  // find all related quotes 
  3.  l_DataRows = List()
  4.  v_QuoteRefID = "0"
  5.  v_CrmOppID = "0"
  6.  v_OwnerName = <AppOwner>
  7.  v_AppLinkName = <AppName>
  8.  v_FormLinkName = <FormName>
  9.  v_ViewLinkName = <ReportName>
  10.  if(!isnull(salesorder.get("salesorder_id"))) 
  11.  { 
  12.      v_CreatorSoID = salesorder.get("salesorder_id")
  13.  } 
  14.  v_SearchCriteria = "Sales_Order_ID==\"" + v_CreatorSoID + "\""
  15.  r_SearchResults = zoho.creator.getRecords(v_OwnerName,v_AppLinkName,v_ViewLinkName,v_SearchCriteria,1,100,"joels_connnection")
  16.  v_ResponseCode = ifnull(r_SearchResults.get("code"),500).toLong()
  17.  if(v_ResponseCode == 3000) 
  18.  { 
  19.      l_HeaderColumns = List()
  20.      l_HeaderColumns.add({"key":"quote_name","value":"Name"})
  21.      l_HeaderColumns.add({"key":"valid_till","value":"Valid Till"})
  22.      l_HeaderColumns.add({"key":"quote_status","value":"Quote Status"})
  23.      l_SearchResults = r_SearchResults.get("data").toJSONList()
  24.      for each  r_Result in l_SearchResults 
  25.      { 
  26.          v_CreatorQuoteID = r_Result.get("ID")
  27.          m_DataRow = Map()
  28.          m_LinkedValue = Map()
  29.          m_LinkedValue.put("value",r_Result.get("Quote_Name"))
  30.          m_LinkedValue.put("isExternal",true)
  31.          m_LinkedValue.put("link","https://app.zohocreator.eu/"+v_OwnerName+"/"+v_AppLinkName+"/"+v_FormLinkName+"/record-edit/"+v_ViewLinkName+"/"+v_CreatorQuoteID+"?param1=my_param_value")
  32.          v_DateTill = "-"
  33.          if(!isnull(r_Result.get("Valid_Till"))) 
  34.          { 
  35.              v_DateTill = r_Result.get("Valid_Till").toDate().toString("dd/MM/yyyy")
  36.          } 
  37.          m_DataRow.put("quote_name",m_LinkedValue)
  38.          m_DataRow.put("valid_till",v_DateTill)
  39.          m_DataRow.put("quote_status",r_Result.get("Quote_Status"))
  40.          l_DataRows.add(m_DataRow)
  41.      } 
  42.  } 
  43.  else 
  44.  { 
  45.      l_HeaderColumns = List()
  46.      l_HeaderColumns.add({"key":"message","value":"Message"})
  47.      // 
  48.      if(v_ResponseCode == 3100) 
  49.      { 
  50.          m_DataRow = Map()
  51.          m_DataRow.put("message","No records found")
  52.          l_DataRows.add(m_DataRow)
  53.      } 
  54.      else 
  55.      { 
  56.          m_DataRow = Map()
  57.          m_DataRow.put("message",r_SearchResults.get("message") + :: " + v_ResponseCode)
  58.          l_DataRows.add(m_DataRow)
  59.      } 
  60.  } 
  61.  // 
  62.  m_RelatedList = Map()
  63.  m_RelatedList.put("header_context",l_HeaderColumns)
  64.  m_RelatedList.put("data",l_DataRows)
  65.  return m_RelatedList; 

Error(s) Encountered
  • Sorry, there was a problem processing your request.: Your returned XML is invalid
  • Sorry, there is a tag discrepancy in the function. The related list cannot be displayed.: You are trying to return <record> </record> (an empty record dataset).


Category: Zoho :: Article: 756

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: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used 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 - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.