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 Inventory: Enable Tracking using the API

Zoho Inventory: Enable Tracking using the API

What?
One of these articles because I spent so long trying different snippets of code to enable tracking when using Deluge code to create an item in Zoho Inventory:
Zoho Inventory: Enable Tracking using the API

Why?
Who uses ZohoInventory for anything else than tracking stock...?

How?
So the quick answer is one missing parameter to send through which is "item_type=inventory"... A little longer, is do ensure you have Zoho Inventory enabled.

But to flesh that out a little more along with setting the other options under "Advanced Tracking"

copyraw
//
// get chart of accounts to use
r_ChartOfAccounts = invokeurl
[
	url :"https://books.zoho.eu/api/v3/chartofaccounts?organization_id=" + v_BooksOrgID
	type :GET
	connection:"zinventory"
];
m_Accounts = Map();
if(!isnull(r_ChartOfAccounts.get("chartofaccounts")))
{
	for each  r_Account in r_ChartOfAccounts.get("chartofaccounts")
	{
		m_Accounts.put(r_Account.get("account_name"),r_Account.get("account_id"));
	}
}
//
// build the update or create request
m_CreateBooksItem = Map();
m_CreateBooksItem.put("name",v_ItemTitle);
m_CreateBooksItem.put("sku",v_ItemSKU);
m_CreateBooksItem.put("rate",v_ItemPrice.toDecimal());
//
// key here to enable inventory tracking
m_CreateBooksItem.put("item_type","inventory");
//
// other less important values to include re purchase information
m_CreateBooksItem.put("product_type","goods");
m_CreateBooksItem.put("reorder_level",0);
m_CreateBooksItem.put("available_stock",v_QuantityAvailable.toLong());
m_CreateBooksItem.put("initial_stock",v_Quantity.toLong());
m_CreateBooksItem.put("initial_stock_rate",v_ItemPrice.toDecimal());
m_CreateBooksItem.put("inventory_account_id",m_Accounts.get("Inventory Asset").toLong());
m_CreateBooksItem.put("purchase_rate",v_PurchaseRate.toDecimal());
m_CreateBooksItem.put("purchase_account_id",m_Accounts.get("Cost of Goods Sold").toLong());
//
// advanced tracking ones
m_CreateBooksItem.put("track_serial_number",true);
m_CreateBooksItem.put("track_batch_number",true);
//
// let's try creating it
r_CreateItem = zoho.inventory.createRecord("items",v_BooksOrgID,m_CreateBooksItem,"zinventory");
info "ITEM CREATE RESPONSE FOR " + v_ItemID;
info r_CreateItem.get("message");
  1.  // 
  2.  // get chart of accounts to use 
  3.  r_ChartOfAccounts = invokeurl 
  4.  [ 
  5.      url :"https://books.zoho.eu/api/v3/chartofaccounts?organization_id=" + v_BooksOrgID 
  6.      type :GET 
  7.      connection:"zinventory" 
  8.  ]
  9.  m_Accounts = Map()
  10.  if(!isnull(r_ChartOfAccounts.get("chartofaccounts"))) 
  11.  { 
  12.      for each  r_Account in r_ChartOfAccounts.get("chartofaccounts") 
  13.      { 
  14.          m_Accounts.put(r_Account.get("account_name"),r_Account.get("account_id"))
  15.      } 
  16.  } 
  17.  // 
  18.  // build the update or create request 
  19.  m_CreateBooksItem = Map()
  20.  m_CreateBooksItem.put("name",v_ItemTitle)
  21.  m_CreateBooksItem.put("sku",v_ItemSKU)
  22.  m_CreateBooksItem.put("rate",v_ItemPrice.toDecimal())
  23.  // 
  24.  // key here to enable inventory tracking 
  25.  m_CreateBooksItem.put("item_type","inventory")
  26.  // 
  27.  // other less important values to include re purchase information 
  28.  m_CreateBooksItem.put("product_type","goods")
  29.  m_CreateBooksItem.put("reorder_level",0)
  30.  m_CreateBooksItem.put("available_stock",v_QuantityAvailable.toLong())
  31.  m_CreateBooksItem.put("initial_stock",v_Quantity.toLong())
  32.  m_CreateBooksItem.put("initial_stock_rate",v_ItemPrice.toDecimal())
  33.  m_CreateBooksItem.put("inventory_account_id",m_Accounts.get("Inventory Asset").toLong())
  34.  m_CreateBooksItem.put("purchase_rate",v_PurchaseRate.toDecimal())
  35.  m_CreateBooksItem.put("purchase_account_id",m_Accounts.get("Cost of Goods Sold").toLong())
  36.  // 
  37.  // advanced tracking ones 
  38.  m_CreateBooksItem.put("track_serial_number",true)
  39.  m_CreateBooksItem.put("track_batch_number",true)
  40.  // 
  41.  // let's try creating it 
  42.  r_CreateItem = zoho.inventory.createRecord("items",v_BooksOrgID,m_CreateBooksItem,"zinventory")
  43.  info "ITEM CREATE RESPONSE FOR " + v_ItemID; 
  44.  info r_CreateItem.get("message")

Error(s) Encountered
  • items with opening stock cannot be deleted, set the opening stock to zero: Guess who's going to have their opening stock set to zero, save the record, then delete it.

Source(s)
Category: Zoho Inventory :: Article: 377

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