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: Mark a package slip as delivered and shipped

Zoho Inventory: Mark a package slip as delivered and shipped

What?
A quick article on a code snippet to mark a package as shipped and delivered in Zoho Inventory.

Why?
As usual, any task like this that takes me longer than an hour, I'd like to document for future use. The use-case is the client has their own delivery drivers and want them to mark a sales order & package as shipped and delivered.

How?
Here's a code snippet that works for me.  It is triggered when a user ticks a decision box in Zoho Creator (on iPad displays as an on/off switch).  My connection here called "jl_inventory" has the minimum required scopes:
  • ZohoInventory.salesorders.READ
  • ZohoInventory.packages.READ
  • ZohoInventory.shipmentorders.CREATE
  • ZohoInventory.shipmentorders.READ
copyraw
//
// init (put your own ZohoBooks/ZohoInventory Org ID
v_BooksOrgID = 123456789;
//
// check the form was ticked and there is a package ID specified
if(input.Mark_as_Complete && input.Zoho_Package_ID != "")
{
	v_PackageID = input.Zoho_Package_ID;
	r_PackageSlip = zoho.inventory.getRecordsByID("packages",v_BooksOrgID.toString(),v_PackageID,"ab_inventory");
	if(r_PackageSlip.get("package") != null)
	{
		if(r_PackageSlip.get("package").get("salesorder_id") != null)
		{
			v_SalesOrderID = r_PackageSlip.get("package").get("salesorder_id");
		}
		if(r_PackageSlip.get("package").get("shipment_order") != null)
		{
			v_ShipmentID = r_PackageSlip.get("package").get("shipment_order").get("shipment_id");
			//
			// if blank then create one
			if(v_ShipmentID == "")
			{
				m_Params = Map();
				m_Params.put("date",zoho.currentdate.toString("yyyy-MM-dd"));
				m_Params.put("delivery_method","My_Own_Drivers");
				m_Params.put("delivered_date",zoho.currentdate.toString("yyyy-MM-dd HH:mm"));
				m_Params.put("tracking_number","N/A");
				l_UrlParams = List();
				l_UrlParams.add("salesorder_id=" + v_SalesOrderID);
				l_UrlParams.add("package_ids=" + v_PackageID);
				l_UrlParams.add("is_delivered=true");
				l_UrlParams.add("organization_id=" + v_BooksOrgID);
				v_Url = "https://inventory.zoho.com/api/v1/shipmentorders?" + l_UrlParams.toString("&");
				r_CreateShipment = invokeurl
				[
					url :v_Url
					type :POST
					parameters:m_Params.toString()
					connection:"jl_inventory"
				];
				info "Created Shipment: ";
				info r_CreateShipment;
				if(r_CreateShipment.get("shipment_order") != null)
				{
					if(r_CreateShipment.get("shipment_order").get("shipment_id") != null)
					{
						v_ShipmentID = r_CreateShipment.get("shipment_order").get("shipment_id");
					}
				}
			}
			//
			// maybe one is either used or created
			if(v_ShipmentID != "")
			{
				v_Url = "https://inventory.zoho.com/api/v1/shipmentorders/" + v_ShipmentID + "/status/delivered?organization_id=" + v_BooksOrgID;
				r_Delivered = invokeurl
				[
					url :v_Url
					type :POST
					connection:"jl_inventory"
				];
				info "Marked as Delivered:";
				info r_Delivered;
			}
		}
	}
}
  1.  // 
  2.  // init (put your own ZohoBooks/ZohoInventory Org ID 
  3.  v_BooksOrgID = 123456789
  4.  // 
  5.  // check the form was ticked and there is a package ID specified 
  6.  if(input.Mark_as_Complete && input.Zoho_Package_ID != "") 
  7.  { 
  8.      v_PackageID = input.Zoho_Package_ID; 
  9.      r_PackageSlip = zoho.inventory.getRecordsByID("packages",v_BooksOrgID.toString(),v_PackageID,"ab_inventory")
  10.      if(r_PackageSlip.get("package") != null) 
  11.      { 
  12.          if(r_PackageSlip.get("package").get("salesorder_id") != null) 
  13.          { 
  14.              v_SalesOrderID = r_PackageSlip.get("package").get("salesorder_id")
  15.          } 
  16.          if(r_PackageSlip.get("package").get("shipment_order") != null) 
  17.          { 
  18.              v_ShipmentID = r_PackageSlip.get("package").get("shipment_order").get("shipment_id")
  19.              // 
  20.              // if blank then create one 
  21.              if(v_ShipmentID == "") 
  22.              { 
  23.                  m_Params = Map()
  24.                  m_Params.put("date",zoho.currentdate.toString("yyyy-MM-dd"))
  25.                  m_Params.put("delivery_method","My_Own_Drivers")
  26.                  m_Params.put("delivered_date",zoho.currentdate.toString("yyyy-MM-dd HH:mm"))
  27.                  m_Params.put("tracking_number","N/A")
  28.                  l_UrlParams = List()
  29.                  l_UrlParams.add("salesorder_id=" + v_SalesOrderID)
  30.                  l_UrlParams.add("package_ids=" + v_PackageID)
  31.                  l_UrlParams.add("is_delivered=true")
  32.                  l_UrlParams.add("organization_id=" + v_BooksOrgID)
  33.                  v_Url = "https://inventory.zoho.com/api/v1/shipmentorders?" + l_UrlParams.toString("&")
  34.                  r_CreateShipment = invokeurl 
  35.                  [ 
  36.                      url :v_Url 
  37.                      type :POST 
  38.                      parameters:m_Params.toString() 
  39.                      connection:"jl_inventory" 
  40.                  ]
  41.                  info "Created Shipment: "
  42.                  info r_CreateShipment; 
  43.                  if(r_CreateShipment.get("shipment_order") != null) 
  44.                  { 
  45.                      if(r_CreateShipment.get("shipment_order").get("shipment_id") != null) 
  46.                      { 
  47.                          v_ShipmentID = r_CreateShipment.get("shipment_order").get("shipment_id")
  48.                      } 
  49.                  } 
  50.              } 
  51.              // 
  52.              // maybe one is either used or created 
  53.              if(v_ShipmentID != "") 
  54.              { 
  55.                  v_Url = "https://inventory.zoho.com/api/v1/shipmentorders/" + v_ShipmentID + "/status/delivered?organization_id=" + v_BooksOrgID; 
  56.                  r_Delivered = invokeurl 
  57.                  [ 
  58.                      url :v_Url 
  59.                      type :POST 
  60.                      connection:"jl_inventory" 
  61.                  ]
  62.                  info "Marked as Delivered:"
  63.                  info r_Delivered; 
  64.              } 
  65.          } 
  66.      } 
  67.  } 

Error(s) Encountered
  • {"code": 4,"message": "Invalid value passed for salesorder_id"}: Not sure about what ended up fixing this one. I think I converted the sales order to an invoice and created a package slip for it. The invoice was then sent (payment=unpaid). Not sure which fixed this.
  • {"code": 4,"message": "Invalid value passed for JSONString"}: Quick fix by settings the parameters in the invokeUrl to a string m_Params.toString()
Category: Zoho Inventory :: Article: 348

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