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  For larger projects, check our bespoke pricing structure and receive dedicated support from our hands-on project consultants and developers at

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  You can also visit our website at

Zoho Books / Inventory: Get Item Rate from a Price Book/List

A quick article on how to get the pricebook entry using Zoho Deluge for a specific product in your ZohoBooks or ZohoInventory instance.

This took me the best part of an hour to determine by going through forum posts from 7 years to 2 years ago. The following will work in May 2024 following the API domain change.

The use-case is that the customer wants the item/product rate taken from the item record, if a pricebook is specified and the item exists within it, then it takes the rate from the pricelist. Note that when I refer to pricebook, this is also referred to as the pricelist... and vice-versa.

And in this use-case, my client has added an incredible number of price books/ price lists and then has in excess of 20k items. Previously, the function that would need to get the price book rate post saving a record in Zoho Deluge would fail because it was making too many function statements.

I have this code triggered in a workflow when the sales order is created to do some further calculations based on a surcharge rate held in a custom module. The custom module could only be created in Zoho Books at time of print but Zoho Inventory is where our workflow and code is sitting right now.

The code snippet to get the item record from the price book
Note that I'm using a connection called "zbooks" and it has every permission under the sun (the naughty ZohoBooks.fullaccess.all) but according to documentation (to be taken with a grain of salt), the scope should be ZohoInventory.settings.READ. I have another connection called "zinventory" which is used here to retrieve the item/product record.
// initialize
m_Blank = Map();
// evaluate
v_BooksOrgID = organization.get("organization_id");
// loop through line items
for each m_LineItem in salesorder.get("line_items")
	r_BooksItem = zoho.inventory.getRecordsByID("items", v_BooksOrgID, m_LineItem.get("item_id"), "zinventory");
	m_BooksItem = ifnull(r_BooksItem.get("item"), m_Blank);
	v_BooksItemRate = ifnull(m_BooksItem.get("rate"),0.00);
	v_ThisQuantity = ifnull(m_LineItem.get("quantity"),1);
	info "Line Item Rate: " + v_BooksItemRate;
	info "Line Item Quantity: " + v_ThisQuantity;
	if(m_LineItem.get("pricebook_id") != null && m_LineItem.get("pricebook_id") != "")
		m_Params = Map();
		m_Params.put("organization_id", v_BooksOrgID);
		m_Params.put("pricebook_id", m_LineItem.get("pricebook_id"));
		m_Params.put("item_ids", m_LineItem.get("item_id"));
		m_Params.put("sales_or_purchase_type", "sales");
		v_PriceBookEndpoint = "";
		r_ThisPriceBook = invokeurl
			url : v_PriceBookEndpoint
			type :GET
			parameters: m_Params
		// tests show this only returns the 1 relevant item from a pricebook of many more items
		l_PriceBookItems = ifnull(r_ThisPriceBook.get("items"),{});
		for each m_PriceBookItem in l_PriceBookItems
			if(m_PriceBookItem.get("default_price_brackets").size() > 0)
				m_ThisPriceBookDefault = m_PriceBookItem.get("default_price_brackets").get(0);
				v_BooksItemRate = ifnull(m_ThisPriceBookDefault.get("pricebook_rate"),v_BooksItemRate);
				info "Pricebook Item Default Rate: " + v_BooksItemRate;
				for each m_PriceBracket in m_PriceBookItem.get("price_brackets")
					if(v_ThisQuantity >= m_PriceBracket.get("start_quantity"))
						if(m_PriceBracket.get("end_quantity") != "" && v_ThisQuantity <= m_PriceBracket.get("end_quantity"))
							v_BooksItemRate = ifnull(m_PriceBracket.get("pricebook_rate"),v_BooksItemRate);
							info "Pricebook Item Volume Rate: " + v_BooksItemRate;
						else if(m_PriceBracket.get("end_quantity") == "")
							v_BooksItemRate = ifnull(m_PriceBracket.get("pricebook_rate"),v_BooksItemRate);
							info "Pricebook Item Volume Rate: " + v_BooksItemRate;
	info "Final Item Rate: " + v_BooksItemRate;
  1.  // 
  2.  // initialize 
  3.  m_Blank = Map()
  4.  // 
  5.  // evaluate 
  6.  v_BooksOrgID = organization.get("organization_id")
  7.  // 
  8.  // loop through line items 
  9.  for each m_LineItem in salesorder.get("line_items") 
  10.  { 
  11.      r_BooksItem = zoho.inventory.getRecordsByID("items", v_BooksOrgID, m_LineItem.get("item_id"), "zinventory")
  12.      m_BooksItem = ifnull(r_BooksItem.get("item"), m_Blank)
  13.      v_BooksItemRate = ifnull(m_BooksItem.get("rate"),0.00)
  14.      v_ThisQuantity = ifnull(m_LineItem.get("quantity"),1)
  15.      info "Line Item Rate: " + v_BooksItemRate; 
  16.      info "Line Item Quantity: " + v_ThisQuantity; 
  17.      // 
  18.      if(m_LineItem.get("pricebook_id") != null && m_LineItem.get("pricebook_id") != "") 
  19.      { 
  20.          m_Params = Map()
  21.          m_Params.put("organization_id", v_BooksOrgID)
  22.          m_Params.put("pricebook_id", m_LineItem.get("pricebook_id"))
  23.          m_Params.put("item_ids", m_LineItem.get("item_id"))
  24.          m_Params.put("sales_or_purchase_type", "sales")
  25.          v_PriceBookEndpoint = ""
  26.          r_ThisPriceBook = invokeUrl 
  27.          [ 
  28.              url : v_PriceBookEndpoint 
  29.              type :GET 
  30.              parameters: m_Params 
  31.              connection:"zbooks" 
  32.          ]
  33.          // 
  34.          // tests show this only returns the 1 relevant item from a pricebook of many more items 
  35.          l_PriceBookItems = ifnull(r_ThisPriceBook.get("items"),{})
  36.          for each m_PriceBookItem in l_PriceBookItems 
  37.          { 
  38.              if(m_PriceBookItem.get("default_price_brackets").size() > 0) 
  39.              { 
  40.                  m_ThisPriceBookDefault = m_PriceBookItem.get("default_price_brackets").get(0)
  41.                  v_BooksItemRate = ifnull(m_ThisPriceBookDefault.get("pricebook_rate"),v_BooksItemRate)
  42.                  info "Pricebook Item Default Rate: " + v_BooksItemRate; 
  43.              } 
  44.              if(m_PriceBookItem.get("pricing_scheme")=="volume") 
  45.              { 
  46.                  for each m_PriceBracket in m_PriceBookItem.get("price_brackets") 
  47.                  { 
  48.                      if(v_ThisQuantity >= m_PriceBracket.get("start_quantity")) 
  49.                      { 
  50.                          if(m_PriceBracket.get("end_quantity") != "" && v_ThisQuantity <= m_PriceBracket.get("end_quantity")) 
  51.                          { 
  52.                              v_BooksItemRate = ifnull(m_PriceBracket.get("pricebook_rate"),v_BooksItemRate)
  53.                              info "Pricebook Item Volume Rate: " + v_BooksItemRate; 
  54.                          } 
  55.                          else if(m_PriceBracket.get("end_quantity") == "") 
  56.                          { 
  57.                              v_BooksItemRate = ifnull(m_PriceBracket.get("pricebook_rate"),v_BooksItemRate)
  58.                              info "Pricebook Item Volume Rate: " + v_BooksItemRate; 
  59.                          } 
  60.                      } 
  61.                  } 
  62.              } 
  63.          } 
  64.      } 
  65.      info "Final Item Rate: " + v_BooksItemRate; 
  66.  } 

Code to get all pricebooks
Adding this here on the per chance you want to use this. But the official documentation will give you this as well:
v_BooksOrgID = organization.get("organization_id");
r_AllPriceBooks = invokeurl
	url :""+v_BooksOrgID
	type :GET
  1.  v_BooksOrgID = organization.get("organization_id")
  2.  r_AllPriceBooks = invokeUrl 
  3.  [ 
  4.      url :""+v_BooksOrgID 
  5.      type :GET 
  6.      connection:"zinventory" 
  7.  ]

Code to get a specific pricebook
Adding this here on the per chance you want to use this. But the official documentation will give you this as well (somewhere). Annoyingly, pricebooks are only mentioned in the line item rather than at the header level:
v_BooksOrgID = organization.get("organization_id");
r_ThisPriceBook = invokeurl
	url :""+m_LineItem.get("pricebook_id")+"?organization_id="+v_BooksOrgID
	type :GET
  1.  v_BooksOrgID = organization.get("organization_id")
  2.  r_ThisPriceBook = invokeUrl 
  3.  [ 
  4.      url :""+m_LineItem.get("pricebook_id")+"?organization_id="+v_BooksOrgID 
  5.      type :GET 
  6.      connection:"zinventory" 
  7.  ]

Error(s) Encountered
  • { "code": 37, "message": "The HTTP method GET is not allowed for the requested resource" }
    You can still use GET. For this, I had to change the endpoint to the Books v3 API and push through the parameters as per my code above.
  • For security reasons you have been blocked for some time as you have exceeded the maximum number of requests per minute
    Getting the item specifically from the pricebook using the code above fixed this as previously it was running into too many statement execution limits.

Category: Zoho :: Article: 875

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

Related Articles

Joes Revolver Map


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:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

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