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 http://ascentbusiness.co.uk/zoho-support-2.  For larger projects, check our bespoke pricing structure and receive dedicated support from our hands-on project consultants and developers at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices.

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 http://ascentbusiness.co.uk.

Zoho Books: System Values Maps

What?
A collection of code snippets I seem to be regularly using to generate a dynamic map of system values held in a ZohoBooks instance.

Why?
Rather than hard-coding and having a ton of if..then statements, I can feed these maps a textual value and it returns the ID to use. Some of these can be found elsewhere in my site but I'm putting all of them here just for quick reference.

How?
Note that for the below, the Top Level Domain (or Zoho DataCenter) is EU rather than the COM. I have a connection called "zbooks" and the v_BooksOrgID is the ID of the instance in ZohoBooks; so for multiple instances of ZohoBooks for the same organization, a separate call would need to be made with a different variable org ID.

copyraw
/* *******************************************************************************
	Function:       Map fn_GetSystemValues()
	Trigger:        Snippet to be used at beginning of code to get dynamic maps of system values
	Purpose:		Taxes, Currencies, Payment Terms, Sales Persons, and Nominal Accounts
	Inputs:         -
	Outputs:        -

	Date Created:   2021-09-24 (Ascent Business - Joel Lipman)
					- Initial release
	Date Modified:	???
					- ???
******************************************************************************* */
//
// our made up books org id but enter your own 
v_BooksOrgID=12345678901; 
//
// ---------------------------------
// ZohoBooks Taxes
m_Taxes = Map();
r_Taxes = invokeurl
[
	url :"https://books.zoho.eu/api/v3/settings/taxes?organization_id=" + v_BooksOrgID
	type :GET
	connection:"zbooks"
];
for each  m_Tax in r_Taxes.get("taxes")
{
	m_Taxes.put(m_Tax.get("tax_percentage").toString(),m_Tax.get("tax_id"));
}
info m_Taxes;
// 
// ---------------------------------
// get currencies 
m_Currencies = Map(); 
r_Currencies = invokeUrl 
[ 
    url :"https://books.zoho.eu/api/v3/settings/currencies?organization_id=" + v_BooksOrgID 
    type :GET 
    connection:"zbooks" 
]; 
for each  m_Currency in r_Currencies.get("currencies") 
{ 
    m_Currencies.put(m_Currency.get("currency_code"),m_Currency.get("currency_id")); 
} 
info m_Currencies; 
//
// ---------------------------------
// get payment terms
m_PaymentTerms = Map();
r_PaymentTerms = invokeUrl 
[ 
    url :"https://books.zoho.eu/api/v3/settings/paymentterms?organization_id=" + v_BooksOrgID 
    type :GET 
    connection:"zbooks" 
]; 
l_PaymentTerms = r_PaymentTerms.get("data").get("payment_terms");
for each  m_PaymentTerm in l_PaymentTerms 
{ 
    m_PaymentTerms.put(m_PaymentTerm.get("payment_terms_label"),m_PaymentTerm.get("payment_terms")); 
} 
info m_PaymentTerms; 
//
// ---------------------------------
// get sales persons
m_SalesPersons = Map();
/*
r_SoDetails = zoho.crm.getRecordById("Sales_Orders",p_SoID); 
v_CRMOwnerID = r_SoDetails.get("Owner").get("id"); 
v_Filter = "crm_reference_id=" + v_OwnerID;
*/
// set v_Filter to blank to retrieve all sales persons
v_Filter = "";
r_AllSalesPersons = zoho.books.getRecords("salespersons", v_BooksOrgID, v_Filter, "zbooks"); 
for each  m_SalesPerson in r_AllSalesPersons.get("data")
{ 
    m_SalesPersons.put(m_SalesPerson.get("salesperson_email"),m_SalesPerson.get("salesperson_id")); 
} 
info m_SalesPersons; 
//
// ---------------------------------
// get chart of accounts to use (both sales and purchases)
r_ChartOfAccounts = invokeurl
[
	url :"https://books.zoho.eu/api/v3/chartofaccounts?organization_id=" + v_BooksOrgID
	type :GET
	connection:"zbooks"
];
m_NominalAccounts = Map();
if(!isnull(r_ChartOfAccounts.get("chartofaccounts")))
{
	for each  m_NomAccount in r_ChartOfAccounts.get("chartofaccounts")
	{
		m_NominalAccounts.put(m_NomAccount.get("account_name"),m_NomAccount.get("account_id"));
	}
}
info m_NominalAccounts;
/
// ---------------------------------
// get delivery methods
r_DeliveryMethods = invokeurl
[
	url :"https://books.zoho.eu/api/v3/deliverymethods?organization_id=" + v_BooksOrgID
	type :GET
	connection:"zbooks"
];
m_DeliveryMethods = Map();
if(!isnull(r_DeliveryMethods.get("data")))
{
	if(!isnull(r_DeliveryMethods.get("data").get("delivery_methods")))
	{
		l_DeliveryMethods = r_DeliveryMethods.get("data").get("delivery_methods");
		for each  m_DeliveryMethod in l_DeliveryMethods
		{
			m_DeliveryMethods.put(m_DeliveryMethod.get("delivery_method"),m_DeliveryMethod.get("delivery_method_id"));
		}
	}
}
info m_DeliveryMethods;
  1.  /* ******************************************************************************* 
  2.      Function:       Map fn_GetSystemValues() 
  3.      Trigger:        Snippet to be used at beginning of code to get dynamic maps of system values 
  4.      Purpose:        Taxes, Currencies, Payment Terms, Sales Persons, and Nominal Accounts 
  5.      Inputs:         - 
  6.      Outputs:        - 
  7.   
  8.      Date Created:   2021-09-24 (Ascent Business - Joel Lipman) 
  9.                      - Initial release 
  10.      Date Modified:    ??? 
  11.                      - ??? 
  12.  ******************************************************************************* */ 
  13.  // 
  14.  // our made up books org id but enter your own 
  15.  v_BooksOrgID=12345678901
  16.  // 
  17.  // --------------------------------- 
  18.  // ZohoBooks Taxes 
  19.  m_Taxes = Map()
  20.  r_Taxes = invokeUrl 
  21.  [ 
  22.      url :"https://books.zoho.eu/api/v3/settings/taxes?organization_id=" + v_BooksOrgID 
  23.      type :GET 
  24.      connection:"zbooks" 
  25.  ]
  26.  for each  m_Tax in r_Taxes.get("taxes") 
  27.  { 
  28.      m_Taxes.put(m_Tax.get("tax_percentage").toString(),m_Tax.get("tax_id"))
  29.  } 
  30.  info m_Taxes; 
  31.  // 
  32.  // --------------------------------- 
  33.  // get currencies 
  34.  m_Currencies = Map()
  35.  r_Currencies = invokeUrl 
  36.  [ 
  37.      url :"https://books.zoho.eu/api/v3/settings/currencies?organization_id=" + v_BooksOrgID 
  38.      type :GET 
  39.      connection:"zbooks" 
  40.  ]
  41.  for each  m_Currency in r_Currencies.get("currencies") 
  42.  { 
  43.      m_Currencies.put(m_Currency.get("currency_code"),m_Currency.get("currency_id"))
  44.  } 
  45.  info m_Currencies; 
  46.  // 
  47.  // --------------------------------- 
  48.  // get payment terms 
  49.  m_PaymentTerms = Map()
  50.  r_PaymentTerms = invokeUrl 
  51.  [ 
  52.      url :"https://books.zoho.eu/api/v3/settings/paymentterms?organization_id=" + v_BooksOrgID 
  53.      type :GET 
  54.      connection:"zbooks" 
  55.  ]
  56.  l_PaymentTerms = r_PaymentTerms.get("data").get("payment_terms")
  57.  for each  m_PaymentTerm in l_PaymentTerms 
  58.  { 
  59.      m_PaymentTerms.put(m_PaymentTerm.get("payment_terms_label"),m_PaymentTerm.get("payment_terms"))
  60.  } 
  61.  info m_PaymentTerms; 
  62.  // 
  63.  // --------------------------------- 
  64.  // get sales persons 
  65.  m_SalesPersons = Map()
  66.  /* 
  67.  r_SoDetails = zoho.crm.getRecordById("Sales_Orders",p_SoID)
  68.  v_CRMOwnerID = r_SoDetails.get("Owner").get("id")
  69.  v_Filter = "crm_reference_id=" + v_OwnerID; 
  70.  */ 
  71.  // set v_Filter to blank to retrieve all sales persons 
  72.  v_Filter = ""
  73.  r_AllSalesPersons = zoho.books.getRecords("salespersons", v_BooksOrgID, v_Filter, "zbooks")
  74.  for each  m_SalesPerson in r_AllSalesPersons.get("data") 
  75.  { 
  76.      m_SalesPersons.put(m_SalesPerson.get("salesperson_email"),m_SalesPerson.get("salesperson_id"))
  77.  } 
  78.  info m_SalesPersons; 
  79.  // 
  80.  // --------------------------------- 
  81.  // get chart of accounts to use (both sales and purchases) 
  82.  r_ChartOfAccounts = invokeUrl 
  83.  [ 
  84.      url :"https://books.zoho.eu/api/v3/chartofaccounts?organization_id=" + v_BooksOrgID 
  85.      type :GET 
  86.      connection:"zbooks" 
  87.  ]
  88.  m_NominalAccounts = Map()
  89.  if(!isnull(r_ChartOfAccounts.get("chartofaccounts"))) 
  90.  { 
  91.      for each  m_NomAccount in r_ChartOfAccounts.get("chartofaccounts") 
  92.      { 
  93.          m_NominalAccounts.put(m_NomAccount.get("account_name"),m_NomAccount.get("account_id"))
  94.      } 
  95.  } 
  96.  info m_NominalAccounts; 
  97.  / 
  98.  // --------------------------------- 
  99.  // get delivery methods 
  100.  r_DeliveryMethods = invokeUrl 
  101.  [ 
  102.      url :"https://books.zoho.eu/api/v3/deliverymethods?organization_id=" + v_BooksOrgID 
  103.      type :GET 
  104.      connection:"zbooks" 
  105.  ]
  106.  m_DeliveryMethods = Map()
  107.  if(!isnull(r_DeliveryMethods.get("data"))) 
  108.  { 
  109.      if(!isnull(r_DeliveryMethods.get("data").get("delivery_methods"))) 
  110.      { 
  111.          l_DeliveryMethods = r_DeliveryMethods.get("data").get("delivery_methods")
  112.          for each  m_DeliveryMethod in l_DeliveryMethods 
  113.          { 
  114.              m_DeliveryMethods.put(m_DeliveryMethod.get("delivery_method"),m_DeliveryMethod.get("delivery_method_id"))
  115.          } 
  116.      } 
  117.  } 
  118.  info m_DeliveryMethods; 


Category: Zoho :: Article: 861

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
© 2024 Joel Lipman .com. All Rights Reserved.